Hey guys, I'm having a problem with a meta include. I want to use the page URL in a switch statement to display meta tags based on the URL using $_SERVER['PHP_SELF']; The problem is, the meta.php file is included on all pages using the following example <?php include("http://www.mysite.com/includes/meta.php");?> Code (markup): When $_SERVER['PHP_SELF'] is called in the meta.php file it will show "meta.php" rather than the page thats calling the include. I believe this is because the include command is including the http://www.mysite.com/ rather than being a relative path to the file. I have no idea why the include is used this way, but the site developer wont change it to relative paths (its a large site). How can I get the URL of the page calling the include? I've tried using $_SERVER ["HTTP_REFERER"], this is empty. Any help appreciated.
I don't think I had enough coffee or something. Why would you call $_SERVER['PHP_SELF'] within the meta.php file? It should include itself because it is the "page" doing the calling. As for your other issue the includes should be relative. Using the full url as you have shown above places an unecessay load on the sever and is just plain laziness on the part of the scriptor. Not sure that was 2 cents worth. Maybe I owe you a penny.
Thanks guys. I was using PHP_SELF to get the URL and compare it with a list of others to return a specific title, description and keywords tags. Problem solved, there's no other way... gotta change it for loads of pages now! Fun! Thanks for your replies.
You cant include file that is not your.... because if you include any remote file the server show you just result of PHP code... it would be very easy