Posted by Colin McKinnon on 08/03/06 21:05
jamiesonhale@gmail.com wrote:
> function & getAttribute( $name )
> {
> if ( isset( $this->attributes[ $name ] ) )
> return $this->attributes[ $name ];
> return NULL;
> }
> ...
>
> However, as of version 4.4.2, this throws a "FATAL: Only variable
> references should be returned by reference." error. Unfortunately, my
> host (and several of my client hosts) are stuck on this version.
>
> Is there an elegant way to solve this problem? I want to return a value
> indicating that no such attribute exists.
>
I think that a better solution would be to work with the array keys.
But doesn't this work:
function & getAttribute($name)
{
return $this->attributes[$name];
}
For an inelegant hack:
function &getAttribute($name)
{
static $dummy;
$dummy=NULL;
return (isset($this->attributes[$name]) ?
$this->attributes[$name]
: $dummy);
}
C.
Navigation:
[Reply to this message]
|