path - PHP data processing not outputting -


hi trying external text file print inside php document. code looks fine me when echo not output , not sure why is. can me out new this.

$location = '/applications/mamp/htdocs/phplabs/branches.txt'; $fp = fopen($location, 'r'); if ($fp) { $readin = fread($fp); fclose($fp); } else { echo 'can\'t open input.txt'; } 

not sure you're trying 'echo' have checked if file exists in first place?

your code written as:

$location = '/applications/mamp/htdocs/phplabs/branches.txt';  if (file_exists($location) && $data = file_get_content($location)){     echo $data; } else {   echo 'file not found'; } 

if (file_exists($location) && $file = fopen($location, 'r')){     $file_content = fread($file, filesize($location));     fclose($file); } esle {     echo 'file not found'; } 

see here more: http://php.net/manual/en/function.file-get-contents.php, http://php.net/manual/en/function.filesize.php


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -