Is there a php command which gets the current page's page title? Or even better can it go through the history and grab a selected page's title? <title>How do I get this line of text into my php code?</title> HTML:
Since php is parsed before html code, there is no way to get the title of the page php is executing from. You could set the title in php and echo it out in the actual title tag, but you can't get the title of the page that the code is being executed on. If you need to get the title of another page, you could use a function like file_get_contents and use a regular expression to extract the title from the page. Not sure if that helps any.
You can store the HTML output in a variable instead of printing it, which you can play with it later on (like templates). Peace,
But, you can get using javascript: <script language="javascript"> alert(document.title); </script> Code (markup):
hello use this // USING FILE GET CONTENTS $_pagecontent=file_get_contents("http://www.siteurl.com"); preg_match("/<title>(.*)<\/title>/smU",$_pagecontent, $results); $title=strip_tags($results[0]); // here is the page title