0

I'm using file_get_contents as below and set cron job to run that file every hour, so it opens the described url which is for running some other functions. Now I have two questions completely similar.

<?php
file_get_contents('http://107.150.52.251/~IdidODiw/AWiwojdPDOmwiIDIWDIcekSldcdndudsAoiedfiee1.php');
?>

1) if the above url returns null value, does it store anything on server (temporory value or log)?

2) if the above url returns error, does it store anything like errors or temporary values to server permanently?

Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121

2 Answers2

0

If you are suspecting anything wrong with the above command or want to debug it . You can print the error / success msg with the following code and re-direct it to log file.

$error = error_get_last();
echo $error['message'];
nirajkumar
  • 335
  • 1
  • 3
  • 14
0

The function itself does not leave any trace.

Since you are running this code in a cron job, you cannot directly inspect its output. Therefore you need to log the result to a log file. Look into monolog for instance.

You will then log the result of your function like this :

$contents = file_get_contents( ... );
if($contents == false){
    $log->error("An error occurred");
} else {
    $log->debug("Result", array('content' => $content));
}
Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121