Skip to content

Instantly share code, notes, and snippets.

@samartioli
Created July 1, 2013 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samartioli/5903171 to your computer and use it in GitHub Desktop.
Save samartioli/5903171 to your computer and use it in GitHub Desktop.
fopen does not take include_path into consideration as of HipHop VM v2.1.0-dev. fopen's 3rd param when set to true should take all include paths into consideration when trying to open the file. http://php.net/manual/en/function.fopen.php
A basic folder structure to replicate this is as follows:
./fopen.php
./someIncludeFolder/
./someIncludeFolder/someIncludedFile.php
<?php
$filename = 'someIncludedFile.php';
echo "Include path is: " . get_include_path() . "\n";
set_include_path(
implode(
PATH_SEPARATOR,
array(
'./someIncludeFolder',
get_include_path()
)
)
);
echo "Include path is now: " . get_include_path() . "\n";
if (!$fh = fopen($filename, 'r', true)) {
echo "### INFO: Unable to open someIncludedFile.php\n";
} else {
echo "### INFO: Opened someIncludedFile.php successfully\n";
}
$ php fopen.php
Include path is: .:/usr/share/php:/usr/share/pear
Include path is now: ./someIncludeFolder:.:/usr/share/php:/usr/share/pear
### INFO: Opened someIncludedFile.php successfully
$ hhvm fopen.php
Include path is: ./
Include path is now: ./someIncludeFolder:./
HipHop Warning: No such file or directory in ./fopen.php on line 20
### INFO: Unable to open someIncludedFile.php
<?php
echo "This is someIncludedFile.php";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment