Require_once PHP Error -
Require_once PHP Error -
i've been programming in php several years , never encountered error before.
here's widget.php file:
require_once('fruit.php'); echo "i compiling fine!!!";
and fruit.php file:
$bvar = true;
when these 2 files ^ compiles no errors , "i compiling fine!!!" success message.
now, min move fruit.php file 1 directory level up, , alter widget.php file reflect directory restructuring:
require_once('../fruit.php'); echo "i compiling fine!!!";
now sudden, php warnings & fatal errors:
warning: require_once(../fruit.php) [function.require-once]: failed open stream: no such file or directory in /webroot/app/widget.php on line 1 fatal error: require_once() [function.require]: failed opening required '../fruit.php' (include_path='.:/usr/local/php5/lib/php') in /webroot/app/widget.php on line 1
in years working php, i've never seen require_once() fail before. ideas?!?!
maybe in wrong work directory. bad thought rely on (except explictly want access it) anyway. use
require __dir__ . '/../fruit.php';
or pre-5.3
require dirname(__file__) . '/../fruit.php';
remind, paths starting ..
, or .
not resolved against include-path, against current work directory.
php compiler-errors
Comments
Post a Comment