tuco Posted December 1, 2006 Share Posted December 1, 2006 Hello, Can someone help me with what I *think* is a simple bit of code? On an arbitrary web page, I would like the code to return the web path to that page and including the title of that page. The purpose is to provide folks who might want to link to the page the actual code they need to make the link by cutting and pasting the link into their own site. Something like this: [code]<a href="http://www.phpfreaks.com/example.php">Page Title</a>[/code] Link to comment https://forums.phpfreaks.com/topic/29046-needed-code-to-return-path-of-web-page-including-title/ Share on other sites More sharing options...
taith Posted December 1, 2006 Share Posted December 1, 2006 this'll give you the url of where you are...[code]<?function get_url(){ if(!empty($_SERVER[QUERY_STRING])) return 'http://'.$_SERVER[SERVER_NAME].$_SERVER[PHP_SELF].'?'.$_SERVER[QUERY_STRING]; else return 'http://'.$_SERVER[SERVER_NAME].$_SERVER[PHP_SELF];}?>[/code]and prolly the easiest way of getting the title, would be setting it as a var first...[code]$title="title";echo "<title>$title</title>";echo "<a href=\"get_url()\">$title</a>";[/code] Link to comment https://forums.phpfreaks.com/topic/29046-needed-code-to-return-path-of-web-page-including-title/#findComment-133103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.