Skip to content

Tag: reflection

Can I get the value of a private property with Reflection?

It doesn’t seem to work: It gets into the IF loop, and then throws an error: Property privateProperty does not exist 😐 $ref = new ReflectionProperty($obj, ‘privateProperty’) doesn’t work either… The documentation page lists a few constants, including IS_PRIVATE. How can I ever us…

Finding the PHP File (at run time) where a Class was Defined

Is there any reflection/introspection/magic in PHP that will let you find the PHP file where a particular class (or function) was defined? In other words, I have the name of a PHP class, or an instantiated object. I want to pass this to something (function, Reflection class, etc.) that would return the file s…

PHP equivalent of send and getattr?

If Ruby gets invited to a party and brings: .. and Python gets invited to the same party and brings: .. what does PHP have to bring to the party? Bonus question: If Ruby and Python got jealous of PHP’s party-favors, what English terms would they search for in PHP’s documentation in order to talk a…