Re: Re: unset() something that doesn't exist

From: Date: Wed, 26 Aug 2009 17:13:28 +0000
Subject: Re: Re: unset() something that doesn't exist
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-297310@lists.php.net to get a copy of this message
On 8/25/09 5:01 AM, "Stuart" <stuttle@gmail.com> wrote: > 2009/8/25 Ralph Deffke <ralph_deffke@yahoo.de>: >> causes an error >> Parse error: parse error, expecting T_STRING' or >> T_VARIABLE' or `'$'' in >> C:\wamp\www\TinyCreator\testCrapp6.php on line 42 > > This is a syntax error, not a runtime error. You've clearly done > something wrong. > >> "Tom Worster" <fsb@thefsb.org> wrote in message >> news:C6B87877.11463%fsb@thefsb.org... >>> is it the case that unset() does not trigger an error or throw an >> exception >>> if it's argument was never set? > > Absolutely. > > -Stuart thank you, stuart. in the interest of wrapping up the archive of this thread on topic, may i summarize? in a statement like: unset($something); if $something is not set, i.e. isset($something) would, in the same context, evaluate to false, the statement WILL NOT trigger an error at any level or throw an exception. the reason i ask is this: sometimes it's important to unset a variable at a position in a script where as programmer i don't know if the variable is set or not. session variables are good examples. i sure don't what reports of such unsets in my php error logs. but i also don't want to do: if (isset($something)) unset($something); if i don't need to. and the answer is: i don't. tom

« previous php.general (#297310) next »