<?php
$fp = fopen('php://temp', 'r+');
if (!$fp) {
    echo "not-resource\n";
} else {
    echo "resource-truthy\n";
}

echo ($fp == false ? 'loose-false' : 'loose-not-false'), PHP_EOL;
echo ($fp != false ? 'loose-not-equal-false' : 'loose-equal-false'), PHP_EOL;
echo ((bool) $fp ? 'cast-true' : 'cast-false'), PHP_EOL;
fclose($fp);
