dimanche 9 juillet 2017

php: file_get_contents not working into if-statement

I have this code:

//A
if(condition1)
   {
   //B
   if(condition2)
      {
      //C
      }
   }

and a file_get_contents($url). I want this file_get_contents to run in "//C", but I notice this: in A works properly, but the same instruction, if put in "//B" or "//C", doesn't work, and "condition1" and "condition2" are both verified (when putting other instrution in B or C they work). I also tried this try/catch statement but without success:

try {
$content = file_get_contents($url);

if ($content === false) {
    // THIS is always verified
}
} catch (Exception $e) {
// NEVER RUNS
}

What can I do?

Aucun commentaire:

Enregistrer un commentaire