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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.