Re: [php-49] class path

From: Darcy W. C.
Sent on: Saturday, January 31, 2009 12:27 AM
thanks, jason - that seems to do the trick.


On Jan 31, 2009, at 12:13 AM, Jason K wrote:

> PHP 5, you can use the built-in Reflection class. Even when  
> inheriting, you can still get the filename of the inherited script.  
> Try this:
>
> class ParentClass
> {
>   function showPath() {
>       $reflection = new ReflectionObject($th­is);
>       echo dirname($reflection-­>getFileName());
>   }
> }
>
>
> darcy w. christ wrote:
>> hi everyone,
>>
>>  it's late, i'm tired and stumped.
>>
>>
>>  does anyone know how to get the path to a class from a method in  
>> the parent/super class?
>>
>>  in the example below, i would like to not have to create the  
>> method, showPath() for each Child class.  but i'm stumped how to  
>> get a hold of the child's path from within a method defined in the  
>> parent class.  is this possible?  am i missing something (quite  
>> likely given my state of mind these days)???
>>
>>
>>  class ChildClass extends () {
>>        function showPath() {
>>            echo dirname(__FILE__);    // shows path to ChildClass
>>        }
>>  }
>>
>>
>>  class ParentClass() {
>>        function showPath() {
>>            echo dirname(__FILE__);    // shows path to ParentClass
>>        }
>>  }
>>
>>
>> ~/darcy w. christ
>> 1000camels
>>
>>
>>
>>
>>
>> -- 
>> Please Note: If you hit "REPLY", your message will be sent to  
>> everyone on this mailing list ([address removed])
>> http://php.meetup...­
>> This message was sent by darcy w. christ ([address removed])  
>> from The Seattle PHP Meetup Group.
>> To learn more about darcy w. christ, visit his/her member profile: http://php.meetup...­
>> To unsubscribe or to update your mailing list settings, click here: http://www.meetup...­
>> Meetup Support: [address removed]
>> 632 Broadway, New York, NY 10012 USA
>>
>
>
>
>
> --
> Please Note: If you hit "REPLY", your message will be sent to  
> everyone on this mailing list ([address removed])
> http://php.meetup...­
> This message was sent by Jason K ([address removed]) from The  
> Seattle PHP Meetup Group.
> To learn more about Jason K, visit his/her member profile: http://php.meetup...­
> To unsubscribe or to update your mailing list settings, click here: http://www.meetup...­
> Meetup Support: [address removed]
> 632 Broadway, New York, NY 10012 USA
>
>


~/darcy w. christ
1000camels


Our Sponsors

  • TUNE

    Meeting space and food

  • PluralSight

    PluralSight subscriptions for developer training

  • Siteground

    Information coming Soon

  • O'Reilly

    Disc Code: PCBW is good for 40% off print and 50% off ebooks and videos

  • JetBrains PhpStorm

    Occasional free licenses to raffle off at meetups

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy