Bug #53875 [NEW]: file() fgets() fgetc() will read <?php but not save this
| From: | rosshowatson at gmail dot com | Date: | Fri, 28 Jan 2011 23:31:54 +0000 |
| Subject: | Bug #53875 [NEW]: file() fgets() fgetc() will read <?php but not save this | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-158299@lists.php.net to get a copy of this message | ||
From:
Operating system: Windows XP
PHP version: 5.3.5
Package: Streams related
Bug Type: Bug
Bug description:file() fgets() fgetc() will read <?php but not save this
Description:
------------
If reading a file that contains "<?" this is ignored and any text
afterwards on that line is ignored.
<?php - does not read
<? php - does not read
<?<?
Even with extra spaces before the <? gets shifted to the next line.
The fgetc reads the line and can show the data but lines read with the
file() command ignores the line.
Test script:
---------------
Two files required: phpinfo2.php
<?php - does not read
phpinfo();
<?
< ?
<?php - does not read
<? php - does not read
?>
Second file: readFileViaPHP.php
<?
$lines = file('phpinfo2.php',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
echo '<pre>';
print_r ($lines);
echo '</pre>';
echo '<br />' . "\n";
?>
Expected result:
----------------
You should see all records from phpinfo2.php
Array
(
[0] => <?php - does not read
[1] => phpinfo();
[2] => <?
[3] => < ?
[4] => <?php - does not read
[5] => <? php - does not read
[6] => ?>
)
Actual result:
--------------
Array
(
[0] => phpinfo();
[2] => < ?
[5] => ?>
)
--
Edit bug report at http://bugs.php.net/bug.php?id=53875&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53875&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53875&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53875&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53875&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53875&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53875&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53875&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53875&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53875&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53875&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53875&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53875&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53875&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53875&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53875&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53875&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53875&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53875&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53875&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53875&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53875&r=mysqlcfg