Possible Duplicate:
require_once () or die() not working
I try to include a file with require_once and i get:
Warning: require_once(1) [function.require-once]: failed to open stream: No such file or directory in /var/www/phpscrape/index.php on line 3
Fatal error: require_once() [function.require]: Failed opening required '1' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/phpscrape/index.php on line 3 I can do a cat /var/www/phpscrape/simplehtmldom/simple_html_dom.php which means the path is correct.
The permissions are www-data:www-data same as index.php which is executing. To be sure i also set chmod 777 but that didnt help either.
The command line is:
<? php
require_once("/var/www/phpscrape/simplehtmldom/simple_html_dom.php") or die("no such file");
require_once("var/www/phpscrape/simplehtmldom/simple_html_dom.php") or die("no such file");
Without the / at the beginning
If not working try:
require_once("phpscrape/simplehtmldom/simple_html_dom.php") or die("no such file");
You are hitting a weird side effect of the fact that require
is not a real function, but a language construct.
require
does not require its parameter to be wrapped into parentheses.
Therefore, what require
interprets as the parameter is the full rest of the line:
(("/var/www/phpscrape/simplehtmldom/simple_html_dom.php") or die("no such file"))
which equals 1
.
I would either just drop the die()
(require will die on error anyway) or do a file_exists()
check beforehand.