note 39407 added to function.isset

From: Date: Tue, 27 Jan 2004 18:01:00 +0000
Subject: note 39407 added to function.isset
Groups: php.notes 
Request: Send a blank email to php-notes+get-64269@lists.php.net to get a copy of this message
I was looking for a way to do this in a function: if(!isset($foo)){ $foo="blah"; } and came up with this function SetIfNotSet($Variable,$Default){ global ${$Variable}; if (!isset(${$Variable})) { ${$Variable}=$Default; } } SetIfNotSet("foo","blah"); Im not sure how flexable it is, but it should work. ---- Manual Page -- http://www.php.net/manual/en/function.isset.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39407 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39407&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39407&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64269) next »