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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -