When using the PHP include, how can I find out which file is calling the include? In short, what is the parent’s file filename?
When using the PHP include , how can I find out which file is
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An easy way is to assign a variable in the parent file (before the inclue), then reference that variable in the included file.
Parent File:
Included File:
You could also mess around with
get_included_files()ordebug_backtrace()and find the event when and where the file got included, but that can get a little messy and complicated.