Is it possible to set include_path without using php.ini or .htaccess, affecting all PHP directories?
On my localhost, I tinker with php.ini to set the include_path. But, overtime the line for the include_path in my php.ini has grown and it looks, ummm, unsightly. I'm looking for a way to set include_path like, I can copy-paste a single include line, say <?php include("superfile.php");?>
on all pages, regardless of where they are in the directory tree, where superfile contains all include_path directives.
I've already tried,
<?php
$include_path = $_SERVER["DOCUMENT_ROOT"] . "/more/directories/as/needed/";
ini_set("include_path", $开发者_运维百科include_path);
include("initialize.php");
?>
and saved it on the root folder as superfile.php
. However if I want to set the include path of a file residing at, say root/sub, by way of superfile.php
I need to do <?php include("../superfile.php"); ?>
(with "directory up" dots), defeating my purpose of setting the include_path.
Any suggestions? Thanks!
It sounds like you've removed all of your custom include_path
directives from the php.ini.
To allow all scripts to call <?php include("superfile.php");?>
simply add the one entry to your php.ini include_path
that will allow this, and your set.
精彩评论