file_get_contents() function in PHP is not working

Avatar
  • updated
  • Answered
In my PHP code, I used file_get_contents() function for a long time and it used to work without any problem. But it stopped working recently. I'm wondering why this function has stopped working on my hosting recently?
Avatar
johnpaulb-imhs1
Hello, Thank you for contacting us about an issue with the file_get_contents PHP function. Ensure you have enabled PHP error logging/reporting. Check you are using PHP 4 >= 4.3.0, PHP 5, PHP 7. Also, make sure you syntax is correct, and none of the parameters have changed. file_get_contents(path,include_path,context,start,max_length (from w3schools) Can you provide a link to the scripts for testing? If you have any further questions, feel free to post them below. Thank you, John-Paul
Avatar
Abdul Rauf

Hi I am also getting this error please check this image.

Sometime it works but don't know why its not working

file_put_contents method with $path and $content parameters

Avatar
IMH Support Agent 2

Hello Abdul,

Apologies for the error you're getting.  When I took a look at your error message, it is saying something else that doesn't appear to be related to the PHP function you're specifying.  Your error message is stating:  

illegal length modifier specified "f" in s[np]printf call

As per our previous reply, make sure to have PHP  error logging enabled.  The logged error will give you a better clue related to the issue. If you can provide us a copy of that log, then we can look into it further.

If you have any further questions or comments, please let us know.


Kindest Regards,

Arnel C.