PeejAvery
September 4th, 2005, 02:37 PM
I have searched and can't find it. Is there a way to specify a URL and have PHP read that pages TITLE tag?
|
Click to See Complete Forum and Search --> : HTML Title. PeejAvery September 4th, 2005, 02:37 PM I have searched and can't find it. Is there a way to specify a URL and have PHP read that pages TITLE tag? olivthill September 4th, 2005, 03:09 PM Hi peejavery, Sorry, I don't understand very well the question. As you know, the way to specify a URL is done either - by submitting a form whose action is to go to a specifed URL - by sendind a header containing a URL : header("Location: my_url.php") - by having an "href". About the title tag, as you know, it is a meta tag included in the <head> section of a page. PHP knows it, if PHP has dynamically created that page, or PHP can know it by reading that page like if it were an ordinary file, and searching for the keyword "title". Maybe, you wish that the title would appear, not only in the caption of the browser, but also in the URL field of the browser. This can be done if the server is configured to accept what is called "URL rewriting". Dr. Script September 4th, 2005, 06:15 PM I think he wnats to look at a website, such as http://codeguru.com from his server, and use PHP to grab the title of the page. Me in particular, I don't know a solution. PeejAvery September 4th, 2005, 11:55 PM I think he wnats to look at a website, such as http://codeguru.com from his server, and use PHP to grab the title of the page. Me in particular, I don't know a solution. Exactly. bigBA September 5th, 2005, 06:30 AM ever heard of a function named file? file returns an array with all lines of the target file, which can also be an url. than you could iterate through that array an search for the title tag. another approach is to use file_get_contents. file_get_contents returns the whole content of the target file into one single string. $sContent = file_get_contents('http://de3.php.net/manual/en/function.preg-match.php'); if( preg_match( '/<title>(.*)<\/title>/mi', $sContent, $aMatches) ) { print_r($aMatches); } if all went well, $aMatches[1] contains the pages title (PHP: preg_match - Manual). codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |