PHP – file_get_contents failed to open stream?

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


This topic contains 0 replies, has 1 voice, and was last updated by  Sravan Kumar 6 years, 1 month ago.

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

    Sravan Kumar

    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($
    if ($file_result === false){
    echo "File doesn't exists - Custom errors";
    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.

Send this to a friend