Can you do something like this in PHP:
function foo() { super->foo(); // do something }
Several predefined variables in PHP are "superglobals", which means they are available in all scopes throughout a script. There is no need to do global $variable; to access them within functions or methods. These superglobal variables are: $GLOBALS. $_SERVER.
To call the constructor of the parent class from the constructor of the child class, you use the parent::__construct(arguments) syntax. The syntax for calling the parent constructor is the same as a regular method.
Inheritance is a well-established programming principle, and PHP makes use of this principle in its object model.
Yes, it's called parent::
though.
public function foo() { parent::foo(); // this is not a static method call, even though it looks like one //do something }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With