PHP: My text file only gets read when I add include function -


i new php , working on file handling. have text file of attempting open reading/appending using skeleton script. file outputting , showing opening, when add include function code. have code below, can @ , tell me if doing right because feels right me @ minute , output i'm not 100% positive.

$location = '/applications/mamp/htdocs/phplabs/branches.txt'; include($location);  if (file_exists($location) && $file = fopen($location, 'r')){     $file_content = fread($file, filesize($location));     fclose($file); } else {     echo 'file not found'; } 

change code read , output file below:

$location = '/applications/mamp/htdocs/phplabs/branches.txt'; //include($location); remove include  if (file_exists($location) && $file = fopen($location, 'r')){     $file_content = fread($file, filesize($location));     echo $file_content; //<----echo here display content     fclose($file); } else {     echo 'file not found'; } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -