Bug #52984 [NEW]: PHP executing text from .php file opened with fopen().

From: Date: Mon, 04 Oct 2010 10:39:23 +0000
Subject: Bug #52984 [NEW]: PHP executing text from .php file opened with fopen().
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-154885@lists.php.net to get a copy of this message
From: Operating system: Ubuntu 8.10/9.04, Windows 7 x86 PHP version: Irrelevant Package: *Directory/Filesystem functions Bug Type: Bug Bug description:PHP executing text from .php file opened with fopen(). Description: ------------ While trying to use a PHP script to read the contents of another .php file using fopen(), it appears that PHP might be executing/skipping/altering the text as PHP code instead of treating it as plain text. The result is nothing like as would be expected as shown below, the result is missing lots of text. 2 versions of PHP have been tried 5.3.1 and 5.3.3 on Windows Vista and 7 both x86 and on two versions of Ubuntu server 8.10 & 9.04, the result is the same across all testbeds. Tried using fgets, fread and file_get_contents, all display the same result. This error was reproduced and verified by a colleague. Test script: --------------- Calling script (index.php): ls_execute(); function ls_execute() { $fp = fopen('code.php', 'r') or die('Cannot open that source resource'); while(!feof($fp)) $data .= fread($fp,128); fclose($fp); return $data; } The file to be read (code.php): <?php echo " This is a test!"; ?> Expected result: ---------------- <?php echo " This is a test!"; ?> Actual result: -------------- "; ?> -- Edit bug report at http://bugs.php.net/bug.php?id=52984&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52984&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52984&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52984&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52984&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52984&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52984&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52984&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52984&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52984&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52984&r=support Expected behavior: http://bugs.php.net/fix.php?id=52984&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52984&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52984&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52984&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52984&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52984&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52984&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52984&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52984&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52984&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52984&r=mysqlcfg

« previous php.bugs (#154885) next »