How to use fgetc() function to read a character from a file in PHP

1 Answer

0 votes
if ($fp = fopen('c:/xampp/htdocs/knowrex.com/index.php', 'r'))
{
   while (($ch = fgetc($fp)) !== false) 
      echo "$ch<br />";
} 
else
    echo 'Error open file';  
    
fclose($fp);

/*
run:


?
p
h
p


s
e
s
s
i
o
n
_
s
t
a
r
t
(
)
;
...
 
*/

 



answered Apr 20, 2016 by avibootz
...