note 34180 deleted from functions.returning-values by aharvey

From: Date: Wed, 05 Sep 2012 02:13:39 +0000
Subject: note 34180 deleted from functions.returning-values by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190503@lists.php.net to get a copy of this message
Note Submitter: rusty at socrates dot berkeley dot edu ---- Here's a sick idea. When a function returns no value, if you assign its return value to a variable that variable will be unset. So instead of returning -1 on error just return with no value. For example, function myfunc($myvar) { if ($myvar == "abc") return(1); if ($myvar == "xyz") return(2); return; } $abc = myfunc("def"); if (isset($abc)) echo("a-ok"); else echo("oops");

« previous php.notes (#190503) next »