1
I need to run the parent version of a method overloaded in php, it is possible?
Ex.:
public function delete()
{
// executa código extra e depois executa o método original
super->delete();
}
1
I need to run the parent version of a method overloaded in php, it is possible?
Ex.:
public function delete()
{
// executa código extra e depois executa o método original
super->delete();
}
4
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ô
}
}
0
Yes, it is used parent::
public function delete()
{
// executa código extra e depois executa o método original
parent::delete();
}
Browser other questions tagged php oop
You are not signed in. Login or sign up in order to post.