note 44467 added to function.is-resource

From: Date: Sat, 07 Aug 2004 01:10:58 +0000
Subject: note 44467 added to function.is-resource
Groups: php.notes 
Request: Send a blank email to php-notes+get-74111@lists.php.net to get a copy of this message
Note that the use of is_resource isn't necessary in the example. mysql_connect (along with any other function that would return a resouce, I imagine) returns false on failure, so the same results could be obtained with: <?php $db_link = @mysql_connect('localhost', 'mysql_user', 'mysql_pass'); if (!$db_link) { die('Can\'t connect : ' . mysql_error()); } ?> Or even: <?php $db_link = @mysql_connect('localhost', 'mysql_user', 'mysql_pass') or die('Can\'t connect : ' . mysql_error()); } ?> You'd be more likely to use is_resource AFTER the initial conection, to make sure the variable you intend to use as a resource is, in fact, a connection resource. You might also use is_resource as a sanity-check prior to serializing an object, since resource variables can't be serialized. ---- Manual Page -- http://www.php.net/manual/en/function.is-resource.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44467 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44467&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44467&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#74111) next »