Edit report at http://bugs.php.net/bug.php?id=53875&edit=1
ID: 53875
User updated by: rosshowatson at gmail dot com
Reported by: rosshowatson at gmail dot com
Summary: file() fgets() fgetc() will read <?php but not save
this
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:
I have tried adding the header('Content-Type: text/plain'); statement to
both the main PHP program and the source that it is reading but get the
same results. I have taken the phpinfo2.php file and renamed this to
phpinfo.txt with the same result.
Just now I decided to examine the HTML source code and it does DOES SHOW
THE CODE correctly.
THE BUG IS NOT IN PHP. THE BUG IS IN IE8. In Opera it works
correctly.
The cause is Micr0$0ft.
The data is in what is sent to the browser, the browser fails to read
the HTML correctly and drops lines here there and everywhere.
Work around for IE8 only:
$lines =
file('phpinfo2.txt',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
$lines = str_replace("<", "<", $lines); // replace the < with <
Close the problem/bug as no fix required.
Previous Comments:
------------------------------------------------------------------------
[2011-01-29 01:11:17] [email protected]
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.
------------------------------------------------------------------------
[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