PDA

Click to See Complete Forum and Search --> : Combine a PHP Statement


xxarmoxx
Mar 17th, 2009, 10:27 PM
How can I combine the following into one statment?

$tableCreator = new tableCreator;
$table = $tableCreator->createJSTable();

Thanks

techgnome
Mar 17th, 2009, 10:57 PM
Don't think you can. First line creates an instance of an object, the second uses that new object to call a method which creates another object.


-tg

dclamp
Mar 18th, 2009, 06:20 PM
as techgnome said, you cant. Why do you want to do this?

xxarmoxx
Mar 18th, 2009, 10:05 PM
im a lazy bastard.

dclamp
Mar 18th, 2009, 10:21 PM
that is a terrible reason. It is 1 extra line...

Answer to original question: no.

manavo11
Mar 19th, 2009, 09:50 AM
This?

$table = tableCreator::createJSTable();

xxarmoxx
Mar 19th, 2009, 08:49 PM
Thanks!

penagate
Mar 19th, 2009, 08:55 PM
that is a terrible reason. It is 1 extra line...

Answer to original question: no.
It's a perfectly valid reason.

penagate
Mar 19th, 2009, 08:59 PM
This?

$table = tableCreator::createJSTable();
This approach requires that the method is declared static.