note 68372 deleted from function.proc-open by cmb

From: Date: Sun, 01 Dec 2019 09:09:20 +0000
Subject: note 68372 deleted from function.proc-open by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213341@lists.php.net to get a copy of this message
Note Submitter: Docey ---- if your writing a function that processes a resource from another function its a good idea not only to check whether a resource has been passed to your function but also if its of the good type like so: <?php function workingonit($resource){ if(is_resource($resource)){ if(get_resource_type($resource) == "resource_type"){ // resource is a resource and of the good type. continue }else{ print("resource is of the wrong type."); return false; } }else{ print("resource passed is not a resource at all."); return false; } // do your stuff with the resource here and return } ?> this is extra true for working with files and process pipes. so always check whats being passed to your functions. here's a small snipppet of a few resource types: files are of type 'file' in php4 and 'stream' in php5 'prossess' are resources opened by proc_open. 'pipe' are resource opened by popen. btw the 'prossess' resource type was not mentioned in the documentation. i make a bug-report for this.

« previous php.notes (#213341) next »