[英]PHP include and require not working in ubuntu even after setting the include_path
Below is my include path as shown by phpinfo()
下面是我的包含路径,如phpinfo()
所示
include_path .:/usr/share/php:/usr/share/pear:/var/www/html/WebPHP
There is a page in /var/www/html/WebPHP/frags
dir that I want to include in my index.php. /var/www/html/WebPHP/frags
目录中有一个页面,我想将其包含在index.php中。
But nothing works. 但是什么都行不通。
What I am doing wrong? 我做错了什么?
Edit 编辑
<?php
set_include_path("/var/www/html/WebPHP/frags");
ini_set('include_path', '/var/www/html/WebPHP/frags')
include 'frags/GuestHeader.php';
echo phpinfo();
?>
If you only want to include one specific file, you should add in your index.php file : 如果只想包含一个特定文件,则应在index.php文件中添加:
require_once '/path/to/your/file.php';
However, if your really want to include the whole directory, you can do : 但是,如果您确实要包括整个目录,则可以执行以下操作:
set_include_path(get_include_path() . PATH_SEPARATOR . '/path/to/your/directory');
Edit : if it still doesn't work, you can do something like : 编辑:如果仍然不起作用,则可以执行以下操作:
foreach (glob("/your/directory/*.php") as $filename) {
require_once $filename;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.