Re: include orgin
| From: | haiwen zhu | Date: | Fri, 04 Apr 2014 07:26:37 +0000 |
| Subject: | Re: include orgin | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323152@lists.php.net to get a copy of this message | ||
On Fri, Apr 4, 2014 at 1:22 PM, Jim Lucas <lists@cmsws.com> wrote:
> On 4/3/2014 9:18 PM, haiwen zhu wrote:
>
>> Hi all,
>> I have 2 fiels,
>> a.php
>>
>> *<?php*
>> *include 'b.php';*
>>
>> b.php
>> *<?php*
>> *echo __FILE__;//i want to know a.php include me.*
>>
>>
>> I wonder if there is a way to know who include me in b.php?
>>
>>
> I can think of a few different variables that can give you this info.
> Depends on your usage though...
>
> echo basename($_SERVER['PHP_SELF']);
> echo basename($_SERVER['SCRIPT_NAME']);
> echo basename($_SERVER['REQUEST_URI']);
> echo basename($_SERVER['PATH_INFO']);
>
> $path_parts = pathinfo('/path/to/script.php');
> echo $path_parts['basename'];
>
> Hope this gets you the info you are looking for.
>
> Jim Lucas
>
I think this is a way to get what i want, thanks for your replay:-)
--
Best Regards,
HaiwenZhu