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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -