I\'ve just started to practice with PHP built-in gettype()
and its return value. This function is capable to return testing result such as boolean
,
Here is one unknown type for you:
$f = fopen('somefile.txt','r');
echo gettype($f); // resource
fclose($f);
echo gettype($f); // unknown
Basically, whenever a resource pointer is closed, the variable holding the handle will point to an unknown resource. Another example would be with GD'S imagecreate/imagedestroy.
Note: as of PHP 7.2, this no longer holds true. gettype
will return resource (closed)
then.