modify a method/function at runtime

Posted by mononym on Stack Overflow See other posts from Stack Overflow or by mononym
Published on 2010-05-28T18:56:28Z Indexed on 2010/05/28 19:11 UTC
Read the original article Hit count: 164

Filed under:
|

I've been looking at the php reflection methods, what i want to do is inject some code after the method is opened and before any return value, for example i want to change:

function foo($bar)
{
    $foo = $bar ;
    return $foo ;
}

And inject some code into it like:

function foo($bar)
{
    //some code here
    $foo = $bar ;
    //some code here
    return $foo ;
}

possible?

© Stack Overflow or respective owner

Related posts about php

Related posts about reflection