Discussion:
include orgin
haiwen zhu
2014-04-04 04:18:42 UTC
Permalink
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?
--
Best Regards,
HaiwenZhu
Jim Lucas
2014-04-04 05:22:52 UTC
Permalink
Post by haiwen zhu
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
haiwen zhu
2014-04-04 07:26:37 UTC
Permalink
Post by Jim Lucas
Post by haiwen zhu
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
Continue reading on narkive:
Loading...