#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Ithaca
    Posts
    68
    Rep Power
    2

    About Reflection API


    Well I was wondering though, you can evaluate a class method or property in the following two possible ways:

    Approach 1:
    PHP Code:
    $class = new ReflectionClass($class);
    $method $class->getMethod($method);
    $property $class->getProperty($property); 
    Approach 2:
    PHP Code:
    $method = new ReflectionMethod($class$method);
    $property = new ReflectionProperty($class$property); 
    But which one is better? Is there a performance advantage/disadvantage between these two? Or is it really just a matter of preference?
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    For all practical applications there is no performance difference between them. It doesn't matter which one you use.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Ithaca
    Posts
    68
    Rep Power
    2
    Originally Posted by E-Oreo
    For all practical applications there is no performance difference between them. It doesn't matter which one you use.
    I see, so its just a matter of choice then? Thx the reply.

IMN logo majestic logo threadwatch logo seochat tools logo