Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6755593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:25:19+00:00 2026-05-26T13:25:19+00:00

$fp = fopen( $myFile, r ); //if echo $fp => I GOT NULL fclose($fp);

  • 0
$fp = fopen( $myFile, "r" );

//if echo $fp => I GOT NULL 

fclose($fp);

But if I do file_get_contents($myFile); I got the string data of that file.

My file ( fedora os )

-rw-r--r-- 1 apache appli 104  2 nov.  12:54 12_62_xxx.log
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:25:20+00:00Added an answer on May 26, 2026 at 1:25 pm

    $fp is a handle, it’s not some real data from the file. You can use this handle in other funcitons, such as fread or fclose.
    file_get_contents internally opens the file, reads it, closes the file and returns the string. That’s why when you print the result of the last one you get the file’s contents.

    Try echo fgets($fp) and see what you get.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The iPhone SDK docs claim fopen() is a supported method of file access but
I have c code like. FILE * fin = fopen(myfile, rb); if (fin ==
If I have: const char *mystr = cheesecakes; FILE *myfile = fopen(path/to/file.exe,r); I need
I am trying to get the (pre-processed) content of an external PHP file: file_get_contents('http://www.example.org/myfile.php');
fopen is failing when I try to read in a very moderately sized file
So: @fopen($file); Ignores any errors and continues fopen($file) or die(Unable to retrieve file); Ignores
$fp = fopen(http://feeds.reuters.com/Reuters/PoliticsNews?format=xml,r) or die(Error reading RSS data.); The above coding working correctly in
I'm using fopen to read from a file $fh = fopen($path, 'r') or die('Could
I'm using fopen in C to write the output to a text file. The
The code chokes at fopen(): <?php ini_set('display_errors',1); error_reporting(E_ALL); $fp = fopen(/path/to/file/some_file.txt,a) or die(can't open

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.