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 Link to comment https://forums.phpfreaks.com/topic/114131-class-method-call/ 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(); Link to comment https://forums.phpfreaks.com/topic/114131-class-method-call/#findComment-586635 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? Link to comment https://forums.phpfreaks.com/topic/114131-class-method-call/#findComment-586649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.