This is what I've done:-

Code:
if (!isset($_SERVER['HTTP_REFERER'])) {  // Check the url they came from
  $url = "Unknown"; // If no URL then show the words Unknown
  }
else { 
  $url = $_SERVER['HTTP_REFERER']; // Shows the URL
    $page = new DOMDocument(1.0);
    $page->loadHTML(file_get_contents($url));
  
    $title = $pages->getElementsByTagName('title')->item(0)->nodeValue;
  }
And where it shows:

Code:
ImageString ($back, 5, 170, 100, "$title", $textcolor);
But it doesn't work.