Stream online/offline

What is wrong with my php code?

$data = @file_get_contents("");
$json = json_decode($data);
  if (($json->stream === "NULL") || ($json->stream === "null")) {
    echo "Stream is offline!";
  else {
    echo "Stream is online!";

I’m offline right now, but it still shows online!

When I do a var_dump($json->stream) in the else part it shows NULL.

=== is strict comparison. So null is only true against null. “null” is a string.

The API returns actual null, not "null" string.

$ php -r 'var_dump(null);'
$ php -r 'var_dump("null");'
string(4) "null"

Thanks guys

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.