topcoder1 Posted July 10, 2008 Share Posted July 10, 2008 <?php class Test{ function oops(){ echo("oops"); } } new Test().oops(); ?> error: Call to undefined function: oops() any idea? thanks Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 10, 2008 Share Posted July 10, 2008 Wrong syntax.... o-O <?php class Test { public function oops() { echo 'oops."; } } new Test()->oops(); Quote Link to comment Share on other sites More sharing options...
topcoder1 Posted July 10, 2008 Author Share Posted July 10, 2008 Wrong syntax.... o-O <?php class Test { public function oops() { echo 'oops."; } } new Test()->oops(); thanks, but even this doesn't work. Parse error: syntax error, unexpected T_OBJECT_OPERATOR I have to say: <?php class Test { public function oops() { echo 'oops."; } } $t=new Test(); $t->oops(); ?> I am using php4 though. Is there a way to not to create a temporary reference before calling the class member function? I mean is there a way to say invoke oops function on new Test() directly? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.