<?php
class Example {
function foo() {
return "foo!\n";
}
}
$e = new Example();
echo "Before: " . $e->foo();
runkit_method_redefine(
'Example',
'foo',
'',
'return "bar!\n";',
RUNKIT_ACC_PUBLIC
);
echo "After: " . $e->foo();
?>
The above example will output: