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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/25/09 5:01 AM, "Stuart" <stuttle@xxxxxxxxx> wrote:

> 2009/8/25 Ralph Deffke <ralph_deffke@xxxxxxxx>:
>> 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@xxxxxxxxxx> wrote in message
>> news:C6B87877.11463%fsb@xxxxxxxxxxxxx
>>> 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



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux