How can I use Reflection to extend a class in runtime?
I need A class is extended from B class.
class A{
function methodA()
{
echo 'This is method A';
}
}
class B{
function methodB()
{
echo 'This is method B';
}
}
You can't do it using reflection, but you could using runkit. I really, really wouldn't recommend doing it though; if a class should extend another class, make it so from the beginning.
You cannot. As the name suggests, Reflection is for reflection alone, gathering data about the code, and not modification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With