Reputation: 5373
$json = file_get_contents($url);
$json_output = json_decode($json, TRUE);
var_dump($json_output);
if($json_output){
echo "TRUE";
} else {
echo "FALSE";
}
the data from var_dump($json_output) is
boolean true
followed by TRUE
from my if statement unless I remove var_dump($json_output), then nothing happens and TRUE does not get printed out either. Why does this happen?
Upvotes: 1
Views: 263
Reputation: 48887
One could ascertain that when you removed the var_dump
line you committed an editing mistake, which caused a syntax error (or the like) and since you have error reporting turned off, you don't see any output.
var_dump
does not affect the value of a variable and, therefore, does not affect its conduct in a conditional.
$json = json_encode(true);
$json_output = json_decode($json, TRUE);
//var_dump($json_output);
if($json_output){
echo "TRUE";
} else {
echo "FALSE";
}
// output: TRUE
Upvotes: 1