Re: Function returning a reference - how ?!?

From: Date: Sun, 22 Dec 2002 05:39:31 +0000
Subject: Re: Function returning a reference - how ?!?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-129099@lists.php.net to get a copy of this message
I'll try.
/* This function instantiates and returns a new Parent class. */ function createParent() {
    return new Parent;
} /* $p is a reference of the Parent object created by createParent(). */ $p = &createParent();
I believe the problem occurs here. $p becomes a reference to the createParent() function whose return value is the Parent object. This *should* work: function createParent() { //the lack of the '()' might have caused other problems return &new Parent(); } $p = createParent(); That way $p equals the value that is returned by the function createParent, which is a reference to the Parent object. Then again, I haven't tested any of this, just going on some instinct here. -- Kyle Gibson admin(at)frozenonline.com http://www.frozenonline.com/

« previous php.general (#129099) next »