Kryptix Posted March 26, 2012 Share Posted March 26, 2012 Is there a way to get what page included it? For example, if index.php includes header.php, how can header.php display 'index.php' automatically? Quote Link to comment https://forums.phpfreaks.com/topic/259768-how-to-obtain-the-parent-page/ Share on other sites More sharing options...
Drummin Posted March 26, 2012 Share Posted March 26, 2012 Not sure about an "automatic" way but how hard is it to add a variable at the top of each page? $pagename="index.php"; You could easily display or use this variable as needed. Quote Link to comment https://forums.phpfreaks.com/topic/259768-how-to-obtain-the-parent-page/#findComment-1331369 Share on other sites More sharing options...
samshel Posted March 26, 2012 Share Posted March 26, 2012 Check this out: http://php.net/manual/en/function.get-included-files.php Quote Link to comment https://forums.phpfreaks.com/topic/259768-how-to-obtain-the-parent-page/#findComment-1331376 Share on other sites More sharing options...
Drummin Posted March 26, 2012 Share Posted March 26, 2012 Any dangers of using get_included_files()? Seems like you'd need to do some excluding to avoid things like database access, footer, menus or other included parts though the function is cool. Wouldn't want to show things that otherwise would be hidden. Quote Link to comment https://forums.phpfreaks.com/topic/259768-how-to-obtain-the-parent-page/#findComment-1331389 Share on other sites More sharing options...
samshel Posted March 27, 2012 Share Posted March 27, 2012 Of course you would need to do some excluding... This function is for internal decision making and not to display the results as is. Assuming most of the files you would want to exclude are common to all pages, you can show the third element from the array [just an example] as the parent page if first 2 elements are dbconnection and config files. It is totally up-to-you. Quote Link to comment https://forums.phpfreaks.com/topic/259768-how-to-obtain-the-parent-page/#findComment-1331395 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.