3
I would like to know in PHP how do I find out which is the parent file, in an inclusion, through the child file.
Example:
- avo.php
- pai.php
- php son.
In the archive avo.php
I have:
include_once 'pai.php';
And in the archive pai.php
I have:
#pai.php include_once 'filho.php';
- Through the archive
filho.php
, how can I discover that it is included bypai.php
? - How can I find out, atavés de
filho.php
, thatpai.php
is included byavo.php
?
I do not know if there is a native method that does this, but if you need to know who is the "father" to do something dynamized in the child, an alternative would be to overwrite the include function, writing the name of the class that is performing include in a variable, then in the child you have access to this variable and respectively the name.
– Luis Henrique
Actually, the goal is to find out where inclusion comes from. I’m in an application where I use
filho.php
, however I do not know who is the file that includes this class. You understand?– Wallace Maxters