Re: help with passing a null argument as reference, please

From: Allan Rydberg (alrdbg_at_southtech.net)
Date: 07/01/04


Date: Thu, 01 Jul 2004 16:53:32 +0200


no! NULL itself cannot be interpreted as a REFERENCE[!!!] and you'd
get: [Fatal error: Cannot pass parameter 1 by reference...]
that's the whole point....

and if you try this at home, use the4 following to be fully
compliant:

   function &addObj(& $obj,$data){
         #----------^ !!!!!
         ...
         ...
         return $some_new_obj;
   }

Andrew @ Rockface wrote:

> Allan Rydberg wrote:
>
>>please help! does anyone know the proper way to pass null as an
>>argument to a function that expects a reference?
>>i have a function that receives an object and attaches it to
>>another object in a hierarchical node-like fashion. it returns the
>>new node:
>>
>> $level5 =& $myNodes->addObj($level4, $data);
>>
>>all works fine, but for the case of the top level node, where i'd like
>>to pass 'null' or 'no object' as the node to attach to:
>>
>> $level0 =& $myNodes->addObj('', $data);
>
>
> $level0 =& $myNodes->addObj(NULL, $data);
>



Relevant Pages