I was wondering how I could overload a standard function in php. Specifically, I’m trying to implement security checks on certain functions. As such, I would like to redefine write as:
function fwrite($handle, $string, $length = null) {
if (doMyChecks()) {
original_fWrite($handle, $string, $length);
} else {
recordViolation();
}
}
I’m using CodeIgniter, so I would put this code in index.php to make it applicable for all pages called through the framework.
It seems that you could use the PHP function
override_function(). From the PHP.net site: