Search code examples
phpcrondatastoretemp

Does file_get_contents store any data


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?


Solution

  • 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));
    }