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] Quote Link to comment 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] Quote Link to comment 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.