Page 1 of 1

using new and ->

Posted: Tue Feb 04, 2003 4:25 am
by Guy
i tried to do this:

Code: Select all

new myObj()->Print();
i get an error and need to do this:

Code: Select all

$obj = new myObj();
$obj->Print();
is it possible to do it the first way?
Guy

Posted: Tue Feb 04, 2003 4:30 am
by bionicdonkey
it looks like u are trying to create a new alias for a pre-definded function. why??

Posted: Tue Feb 04, 2003 4:39 am
by twigletmac
AFAIK, it is not possible to use the syntax in your first method.

Mac

Posted: Tue Feb 04, 2003 4:49 am
by bionicdonkey
i don't think it would be legal...looks pointless

it is something you can do in c++ and i wondered

Posted: Tue Feb 04, 2003 6:32 am
by Guy
if it is possible in php also.
it makes a nicer code in my opinion.
because i only want to print the object and destroy it afterwards.