ronnievanderstegen Posted February 28, 2013 Share Posted February 28, 2013 Hi I wanted to open, read and close a file using following code: <?php $filename="test.txt"; $handle= fopen ($filename, "r"); $contents=fread($handle,filesize($filename)); fclose ($handle); ?> This file is located in the map: /users/sites/test.txt But opening the .php file on my local browser doesn't do a thing. I only get a blanc screen. I thought that file permission could be the problem, but I don't know what to change. Does anyone have any experience with this on Mac and how to solve it? Thanks already. Quote Link to comment https://forums.phpfreaks.com/topic/275057-fopen-mac/ Share on other sites More sharing options...
Christian F. Posted February 28, 2013 Share Posted February 28, 2013 (edited) You'll need to turn on error reporting. Please read the following post for how to do that. That said, why aren't you using file_get_contents? Edited February 28, 2013 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/275057-fopen-mac/#findComment-1415614 Share on other sites More sharing options...
kicken Posted February 28, 2013 Share Posted February 28, 2013 But opening the .php file on my local browser doesn't do a thing. I only get a blanc screen.Unless you're doing something else that you didn't show, then that would be expected. Your sample script does not produce any output. Add echo $contents; to have it display the contents of the file. Quote Link to comment https://forums.phpfreaks.com/topic/275057-fopen-mac/#findComment-1415625 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.