关于PHP中require的问题
1.使用PHP中require如何包含一个文件夹中的所有文件?
require("./folder/*")是不行的,难道PHP中不能像Java中的include一样灵活方便吗?
不能正则识别名称吗?模式识别?
2。不用require同一个类两次?
file name: A_Dao.class.php
function: contain basic operations of A.class
A_Dao.class.php
require("DBConnection.class.php");
...
...
...
?>
another file: B_Dao.class.php
function: contain basic operations of B.class
B_Dao.class.php
require("DBConnection.class.php");
...
...
...
?>
A and B.class are entities as abstracted from conceptions.
ServiceA.class.php
require("./dao/A_Dao.class.php");
require("./dao/B_dao.class.php");
...
...
...
?>
run ServiceA.class.php
"Fatal error: Cannot redeclare class DBConnection in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\application\dao\DBConnection.class.php on line 3"
What's wrong?
为什么不能重复require相同的(DBConnection.class.php)?
编译器不会总动处理吗(像Java一样)?