Bug #53875 [Opn->Bgs]: file() fgets() fgetc() will read <?php but not save this
Edit report at http://bugs.php.net/bug.php?id=53875&edit=1
ID: 53875
Updated by: scottmac@php.net
Reported by: rosshowatson at gmail dot com
Summary: file() fgets() fgetc() will read <?php but not save
this
-Status: Open
+Status: Bogus
Type: Bug
Package: Streams related
Operating System: Windows XP
PHP Version: 5.3.5
Block user comment: N
Private report: N
New Comment:
It's be interpreted as HTML tags, hence why it goes 0, 2, 5.
add
header('Content-Type: text/plain'); to the top or click view source.
Previous Comments:
------------------------------------------------------------------------
[2011-01-29 00:31:53] rosshowatson at gmail dot com
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 this bug report at http://bugs.php.net/bug.php?id=53875&edit=1
Thread (3 messages)