Jump to content

fopen() mac


ronnievanderstegen

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/275057-fopen-mac/
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/275057-fopen-mac/#findComment-1415625
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.