Can i capture the title of a page and use it in a variable

is it possible to capture the title of a page using php or javascript?

Im making a link to this page link and i want to be able to put it on a lot of pages without having to make the links for each page.

I figured out how to capture the page url but now i need to capture the page title for my link text.

this is the php i used to get the current page url


<?php
  $domain = $_SERVER['HTTP_HOST'];
  $path = $_SERVER['SCRIPT_NAME'];
  $queryString = $_SERVER['QUERY_STRING'];
  $currenturl = "http://" . $domain . $_SERVER['REQUEST_URI'];
?>

Then i printed it out into a text area an dthe link wokrs fine its the “text” of the link im having a problem with


  <textarea readonly="true"  cols="35" rows="35" wrap="soft">
 <?php print "<a href=\"".$currenturl."\"".">"."text"."</a>"; ?>
  </textarea>

any ideas?