PHP – file_get_contents failed to open stream?

Home Forums PHP Code Snippets PHP – file_get_contents failed to open stream?

Tagged: 

This topic contains 0 replies, has 1 voice, and was last updated by  Sravan Kumar 5 years, 3 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #3645

    Sravan Kumar
    Keymaster

    Whenever you are trying to get the contents of external or internal file, file_get_contents() is the function we use. We can even check whether the external file exists or not with this method, following is the simple code which checks whether the external or internal file exists and can add your own custom error message when returns an error:


    $file_result = file_get_contents($
    file_result);
    if ($file_result === false){
    echo "File doesn't exists - Custom errors";
    }else{
    echo "File access is successful, you can continue with coding";
    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Ignite Your Thoughts

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Send this to a friend