I need to run the parent version of an overloaded method in php, is it possible?
Ex:
public function delete()
{
// executa código extra e depois executa o método original
super->delete();
}
I need to run the parent version of an overloaded method in php, is it possible?
Ex:
public function delete()
{
// executa código extra e depois executa o método original
super->delete();
}
When there are more inheritance levels it may be necessary to use the class name instead of parent
, the code snippet below exemplifies the uses for each case.
<?php
class Foo {
public function exemplo() {}
}
class Bar extends Foo {
public function exemplo() {
parent::exemplo(); // chama da classe pai: Foo::exemplo()
}
}
class Foobar extends Bar {
public function exemplo() {
parent::exemplo(); // chama da classe pai: Bar::exemplo()
Foo::exemplo(); // chama da classe avô
}
}
Yes, use parent::
public function delete()
{
// executa código extra e depois executa o método original
parent::delete();
}