At 16:54 14/06/2005, Sebastian Mendel wrote:
Ron Korving wrote:

>> function ifsetor(&$var, $default = null) {
>>     return isset($var) ? $var : $default;
>> }
>>
>> echo ifsetor($a, 'foo');
>> echo $a, $b;
>> echo ifsetor($a, 'foo');
>> echo isset($a) ? 'is set' : 'not set';
>>
>> expected result:
>>
>> foo
>> Notice: Undefined variable: a in [...]
>> Notice: Undefined variable: b in [...]
>> foo
>> not set
>>
>> actual result:
>>
>> foo
>> Notice: Undefined variable: b in [...]
>> foo
>> not set
>
> No, ifsetor() is not possible in user land, because it generates notices,
> and a php core function ifsetor() would not generate notices. That's really
> the way it has to be.

i see no notice produced by this ifsetor()

One is not supposed to be emitted either, variables passed by reference don't generate notices regardless of whether they exist or not, to allow returning data through them. This implementation of issetor() actually works fine, except it does pollute the symbol tables with empty variables ($a and $b in this examples are created, as nulls).

Zeev

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to