For MVC reasons, I want to be able to trigger a function to find when the function has been called, since Codeigniter has functions around their core, I want to hook a function such as setcookie and create a file when it’s been called (from the triggered function) for example:
function call_me()
{
$file = fopen('setcookie.txt', 'a+');
fwrite($file, 'Called at ' . __CLASS__);
fclose();
}
So when setcookie is called, it should trigger the call_me function. Is there any specific function or method to do this? I know about debug_backtrace but that’s not the purpose I want.
What you basically need to have a look at is Observers.
Why don’t you try what is described here :
http://devzone.zend.com/1384/observer-pattern-in-php/