开发者

Does PHP/Apache look for an includes folder by default?

开发者 https://www.devze.com 2023-04-05 20:38 出处:网络
I have recently discovered set_include_path() and have found that the path that is returned is the path to my includes directory.

I have recently discovered set_include_path() and have found that the path that is returned is the path to my includes directory.

Does PHP automatically look for an includes directory and update the include_path to this?

I have also noticed that the few paths that I set with set_include_path are not available inside a Class Method when set outside of the Class itself.

Why is this?

$include_root = $_SERVER['DOCUMENT_ROOT'] . '/path/to/includes/';
$include_paths = get_include_path() . PATH_SEPARATOR .
                 $include_root . PATH_SEPARATOR .
                 $include_root . 'classes/' . PATH_SEPARATOR;

set_include_开发者_StackOverflowpath( $include_paths );

Thanks for all your advice in advance!


this (any "automated" lookup of an includes directory) would be set in a php.ini file. make a test page called test.php containing:

<?php phpinfo(); ?>

point your browser to test.php and look for this variable:

include_path    .:/usr/share/php:/usr/share/pear

you can also find which php.ini file is being used:

Loaded Configuration File   /etc/php5/apache2/php.ini

I don't have an answer for the class methods question.

If you're running from the command line and not through the browser, you can check the ini file using:

php -r "phpinfo();" | less
0

精彩评论

暂无评论...
验证码 换一张
取 消