Home > Backend Development > PHP Tutorial > PHP多层require有关问题,请php高手指教

PHP多层require有关问题,请php高手指教

WBOY
Release: 2016-06-13 10:02:33
Original
746 people have browsed it

PHP多层require问题,请php高手指教!
我是做.net的,对php不是太熟.最近想做一个私人网站,要用php,遇到了一点问题

假设我的网站有这样的目录结构

/classes/a.class.php
/classes/b.class.php
/c.php
a.class.php,b.class.php是两个类,c.php是页面

如果a.class.php中引用(require_once)b.class.php,   c.php引用a.class.php,运行c.php会报错,找不到b.class.php

诸如这样的多层引用的问题,该如何解决呢?

------解决方案--------------------
c.php怎么require的?
------解决方案--------------------
路径是不是没有写对?
------解决方案--------------------
/classes/a.class.php
$basedir = dirname(__FILE__);
require_once($basedir. "b.class.php ");
?>

/classes/b.class.php
$basedir = dirname(__FILE__);
?>

/c.php
$basedir = dirname(__FILE__);
require_once($basedir. "classes/a.class.php ");
?>
------解决方案--------------------
可以使用绝对路径
怎么引都没问题

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template