file_get_contents works in base script but not in an included script
| From: | LinuxManMikeC | Date: | Mon, 18 May 2009 21:54:31 +0000 |
| Subject: | file_get_contents works in base script but not in an included script | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-292750@lists.php.net to get a copy of this message | ||
In PHP4, I am using file_get_contents('file.sql',true) to bring in SQL
queries from files who's directory is on the include path. It works
fine in the main php scripts (ones accessible through URLs), but when
done in a php script that is included by one of the main scripts I
just get false instead of a string. The files exist, the include path
is correctly set at all times (I've checked), and the exact same code
works when placed directly in the main php script. I've been tearing
through documentation for hours. Is there some quirk, or setting I'm
missing? Below is an example of what I'm doing.
main.php
<?php
set_include_path(get_include_path . ':/absolute/path/to/sql');
include('inc.php');
$SQL1 = file_get_contents('query.sql',true);
//$SQL1 == contents of query.sql
?>
includes/inc.php
<?php
$SQL2 = file_get_contents('query.sql',true);
//$SQL2 == false
//My path is still intact here
?>