I am attempting to dynamically grab a page’s title and URL and echo into HTML. Here’s what I have:
<ul>
<li><a href="mailto:?Subject=<?php echo $page_title?>&body=<?php echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>" class="email" title="Email">Email</a>
</li>
</ul>
The URL successfully echos, but I’m not sure if this is the correct way? And I can not figure out how to print the page’s title via <?php echo $page_title?>?
There is no global PHP variable which corresponds to the page
<title>. Unless you earlier used the$page_titlevariable to specify the<title>……
<?php echo $page_title?>wont’ do anything special.If you did use the
$page_titlevariable in this way, you might need to encode the data. It should be both URI encoded and HTML encoded – in that order.