PHP include path error -
i keep getting error when try include simpletest in include_path:
<? set_include_path(get_include_path() . path_separator . realpath(basename(dirname(__file__)) . '/../../')); include 'simpletest/autorun.php'; returns:
.:/usr/lib/php:/users/kristiannissen/documents/php warning: require_once(/users/kristiannissen/documents/php/simpletest/arguments.php): failed open stream: no such file or directory in /users/kristiannissen/documents/php/simpletest/reporter.php on line 13 fatal error: require_once(): failed opening required '/users/kristiannissen/documents/php/simpletest/arguments.php' (include_path='.:/usr/lib/php:/users/kristiannissen/documents/php') in /users/kristiannissen/documents/php/simpletest/reporter.php on line 13
personally view pages first executed, such index.php , view pages should in root of html.
so within index.php can do:
define("base_path",str_replace("\\","/",dirname(__file__))); so base_path equal to: /users/kristiannissen/documents/php/simpletest
so if want phpdirectory in include path should use dirname() go up directory:
//get array of include paths $include_parts = explode(path_separator,get_include_path()); //extend paths $include_parts[] = dirname(dirname(base_path)); //this ../../ //recompile paths , set them set_include_path(implode(path_separator,$include_parts)); this safe way accomplish trying do.
Comments
Post a Comment