using new and ->

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Guy
Forum Commoner
Posts: 53
Joined: Sun Jan 12, 2003 3:34 am

using new and ->

Post 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
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post by bionicdonkey »

it looks like u are trying to create a new alias for a pre-definded function. why??
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

AFAIK, it is not possible to use the syntax in your first method.

Mac
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post by bionicdonkey »

i don't think it would be legal...looks pointless
User avatar
Guy
Forum Commoner
Posts: 53
Joined: Sun Jan 12, 2003 3:34 am

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

Post 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.
Post Reply