Jump to content

class method call


topcoder1

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.