change path for include/require only once
I have a lot of sites - all hosted on my server. I want one of them to access file from /vhos开发者_高级运维t which is a directory above httpdocs where the domain is linked.
I know that there is an option to change the path in httpd.conf but that is a lot of work to change all the includes in my sites.
Use the function ini_set(). For example if you wanted to set your PHP include_path to ".:../:./include:../include" then you would do this in your PHP code:
ini_set("include_path", ".:../:./include:../include");
You can also use ini_set() to affect other PHP settings like auto_prepend_file, auto_append_file, error_reporting, etc.
精彩评论