On Fri, 2008-06-06 at 11:35 -0400, Christoph Boget wrote:
> > The 'new' keyword has to apply to the object created in the constructor (and
> > not the return value of any of the follow-up calls.) To establish this
> > precedence, chaining wasn't allowed on constructors.
>
> If precedence was th
> The 'new' keyword has to apply to the object created in the constructor (and
> not the return value of any of the follow-up calls.) To establish this
> precedence, chaining wasn't allowed on constructors.
If precedence was the issue, why doesn't this work, either:
(new bob())->one()->two()
The 'new' keyword has to apply to the object created in the constructor (and
not the return value of any of the follow-up calls.) To establish this
precedence, chaining wasn't allowed on constructors.
On Fri, Jun 6, 2008 at 11:04 AM, Eric Butera <[EMAIL PROTECTED]> wrote:
> On Fri, Jun 6, 2008
On Fri, Jun 6, 2008 at 11:00 AM, Christoph Boget <[EMAIL PROTECTED]> wrote:
>> > Why? I thought constructors returned the object?
>> It's been a while since I've played with objects in PHP, but couldn't
>> you just add the line:
>> return $this;
>> ...to the end of your __construct() function? Sor
> > Why? I thought constructors returned the object?
> It's been a while since I've played with objects in PHP, but couldn't
> you just add the line:
> return $this;
> ...to the end of your __construct() function? Sorry if this is obtuse of
> me to say, I just thought maybe the answer was that sim
> -Original Message-
> From: Christoph Boget [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 06, 2008 9:45 AM
> To: PHP General
> Subject: [PHP] Method chaining off constructors
>
> Is there a reason why you can't do method chaining off of
constructors?
>
&
Is there a reason why you can't do method chaining off of constructors?
Consider the following class:
class bob
{
public function __construct()
{
echo 'Constructor()';
}
public function one()
{
echo '->one()';
return $this;
}
public function two
'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, November 11, 2002 1:33 PM
Subject: RE: [PHP] method chaining
> Apologies for the previous truncated version of this -- dunno what
happened there!!
>
> > -Original Message-
> > From: Terry McBride
- Original Message -
From: "Ford, Mike [LSS]" <[EMAIL PROTECTED]>
To: "'Terry McBride'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, November 11, 2002 1:33 PM
Subject: RE: [PHP] method chaining
> Apologies for the previous tru
Apologies for the previous truncated version of this -- dunno what happened there!!
> -Original Message-
> From: Terry McBride [mailto:terry@;boxitllc.com]
> Sent: 11 November 2002 15:53
>
> I have a question about php and OO. I want to chain methods
> together having
> them performed o
> -Original Message-
> From: Terry McBride [mailto:terry@;boxitllc.com]
> Sent: 11 November 2002 15:53
>
> I have a question about php and OO. I want to chain methods
> together having
> them performed on the results of the following method.
> Meaning something
> like $foo->get("bar")-
---
From: "Ernest E Vogelsinger" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 11, 2002 12:02 PM
Subject: Re: [PHP] method chaining
> At 17:57 11.11.2002, Terry McBride spoke out and said:
> [snip]
>
me
error.
Terry
- Original Message -
From: "Johan Ohlin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 11, 2002 11:45 AM
Subject: Re: [PHP] method chaining
> If I have understood correctly what you want to do then this will do
fine...
>
> $
s a reference in order to grab it properly!?
I wish I knew why these decisions went the way the did.
Terry
- Original Message -
From: "Maxim Maletsky" <[EMAIL PROTECTED]>
To: "Terry McBride" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monda
If I have understood correctly what you want to do then this will do fine...
$foo->${$foo->get("bar")}->getBaz();
/ Johan
- Original Message -
From: "Terry McBride" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 11, 20
work around:
$obj = $foo->get("bar");
$obj->getBaz();
it is a better way as you don't have to re-repeat the function code and
re-pass the oblect.
--
Maxim Maletsky
[EMAIL PROTECTED]
"Terry McBride" <[EMAIL PROTECTED]> wrote... :
> Hello,
>
> I have a question about php and OO. I want to ch
At 16:53 11.11.2002, Terry McBride spoke out and said:
[snip]
>Hello,
>
>I have a question about php and OO. I want to chain methods together having
>them performed on the results of the following method. Meaning something
>like $foo->get("bar")->getBaz().
Hello,
I have a question about php and OO. I want to chain methods together having
them performed on the results of the following method. Meaning something
like $foo->get("bar")->getBaz().
I get the following error from the script bellow.
Parse error: parse error, unexpected T_OBJECT_OPERATOR,
18 matches
Mail list logo