php - File & file_get_contents bugging on reading simple file -
file or file_get_contents not read sample file properly
<?php
?>
this test program
$flines=file('../include/test.php'); echo '<pre>'; print_r($flines); echo '</pre>'; for($i=0;$i<count($flines);$i++) { echo("$i:".$flines[$i]."\n<br>"); } echo "file contents"; echo(file_get_contents('../include/test.php'));
this output
array (
[0] => ?>
)
0:1:?>
file contents
basically skips php declaration reason... , file empty
addition every works fine when removing opening <
of course
you didn't trick php, php right along; tricked yourself....
$flines=file('./x.php'); echo '<pre>'; print_r(array_map('htmlentities',$flines)); echo '</pre>'; for($i=0;$i<count($flines);$i++) { echo("$i:".htmlentities($flines[$i])."\n<br>"); } echo "file contents"; echo(htmlentities(file_get_contents('./x.php')));
think web browser when encounters < rather <
Comments
Post a Comment