Is there a magic method that when a certain method is called from an object, that a magic method is called first. Kinda like the __call method, but this only gets triggered when the method isn't found.
So in my case i'd like something like this:
class MyClass
{
public function __startMethod ( $method, $args )
{
// a method just got called, so this is called first
echo ' [start] ';
}
public function helloWorld ( )
{
echo ' [Hello] ';
}
}
$obj = new MyClass();
$obj->helloWorld();
//Output:
[start] [Hello]
Does something like this exist in PHP??
__constructit will be called when this part of the code will get executed:$obj = new MyClass();There is only. To answer your question there isn't, you can only prepend a function to the beginning of each function in the class. -.- mario was 40 sec faster :D