monkeybidz Posted April 9, 2009 Share Posted April 9, 2009 I am trying to get vars to my header from whatever page I am currently viewing to print META depending on the page. I have this code in header.php so far: if($SETTINGS['keywordstag'] != '' && $SETTINGS['descriptiontag'] != '') { print " <META name=\"description\" content=\"".file_get_contents('')."\">"; } Not sure if: file_get_contents('') is what I should be using here. Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/153385-help-getting-a-page-content/ Share on other sites More sharing options...
gaza165 Posted April 9, 2009 Share Posted April 9, 2009 If you want to know the current page on which your on. <?php $_SERVER["REQUEST_URI"]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/153385-help-getting-a-page-content/#findComment-805849 Share on other sites More sharing options...
monkeybidz Posted April 9, 2009 Author Share Posted April 9, 2009 I guess what I am trying to do is get the current page content so that google ads will display relevant ads instead of just what is in my header META keywords. Quote Link to comment https://forums.phpfreaks.com/topic/153385-help-getting-a-page-content/#findComment-805853 Share on other sites More sharing options...
gaza165 Posted April 9, 2009 Share Posted April 9, 2009 Have you thought about looking at cURL?? http://uk.php.net/curl Quote Link to comment https://forums.phpfreaks.com/topic/153385-help-getting-a-page-content/#findComment-805855 Share on other sites More sharing options...
monkeybidz Posted April 9, 2009 Author Share Posted April 9, 2009 I used your idea with a bit of mine: $uri = $_SERVER["REQUEST_URI"]; if($SETTINGS['keywordstag'] != '' && $SETTINGS['descriptiontag'] != '') { print " <META name=\"description\" content=\"".file_get_contents('http://www.mysite.com$uri')."\">"; } almost works cause now I get the URI, but just need help with the $uri directly after the .com. How would I use it there? Quote Link to comment https://forums.phpfreaks.com/topic/153385-help-getting-a-page-content/#findComment-805861 Share on other sites More sharing options...
Alexhoward Posted April 9, 2009 Share Posted April 9, 2009 i use: "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ; This will bring back everything in the address bar... is that what you're after...? ignore if not... Quote Link to comment https://forums.phpfreaks.com/topic/153385-help-getting-a-page-content/#findComment-805899 Share on other sites More sharing options...
monkeybidz Posted April 9, 2009 Author Share Posted April 9, 2009 That did the trick! Thanks to all! Quote Link to comment https://forums.phpfreaks.com/topic/153385-help-getting-a-page-content/#findComment-805902 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.