reflection ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Testing reflection in PHP5, but has no luck.


class Foo {
   public $prop;
   function Func($name) {
       echo "Hello $name";
reflection_object::export(new Foo);
reflection_method::export('Foo', 'func');
reflection_property::export('Foo', 'prop');

It did not print anything.... Perhaps someone can tell me what I did wrong.


Re: reflection ?

from the curtain and staggered drunkenly up to the mic. In a
cracked and slurred voice he muttered:

Quoted text here. Click to load it

I think those early docs are a tad inaccurate.


Phil Roberts | Deedle Doot Doo Dee Dee | /

I could be wrong here, You could be right
Please forgive me I have sinned - Not on your life
But that's how you want me, But I'll never fear thee
Why you and not me? Tell me Holy Man

Re: reflection ?

Phil Roberts wrote:
Quoted text here. Click to load it

The classes have been renamed since RC 3:

reflection_class = reflectionClass
reflection_object = reflectionObject



Re: reflection ?

Thanks, I changed then it works.... but how about this? This seem to fail as

Example 14-3. Using the Reflection_Parameter class

    function foo($a, $b, $c) { }
    function bar(Exception $a, &$b, $c) { }
    function baz($a= 1, $b= NULL, Reflection_Function $c) { }
    function abc() { }

    // Create an instance of Reflection_Function with the
    // parameter given from the command line.
    $reflect= new Reflection_Function($argv[1]);

    echo $reflect->toString();
    foreach ($reflect->getParameters() as $i => $param)
            "-- Parameter #%d: %s {\n".
            "   Class: %s\n".
            "   Allows NULL: %s\n".
            "   Passed to by reference: %s\n".
            var_export($param->getClass(), 1),
            var_export($param->allowsNull(), 1),
            var_export($param->isPassedByReference(), 1)

But I just cut and past from the Zend examples
Quoted text here. Click to load it

Re: reflection ?

Sarah Tanembaum wrote:
Quoted text here. Click to load it

*ALL* reflection classes have been renamed, so:

Reflection_Function = now ReflectionFunction

(without the underscore)


Re: reflection ?

Quoted text here. Click to load it

It looks like they are trying to follow Java's naming convention:
camelCase ;-)
 |im |yler /  Remove lock to reply.

Site Timeline