|
-
September 4th, 2005, 02:37 PM
#1
HTML Title.
I have searched and can't find it. Is there a way to specify a URL and have PHP read that pages TITLE tag?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 4th, 2005, 03:09 PM
#2
Re: HTML Title.
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".
-
September 4th, 2005, 06:15 PM
#3
Re: HTML Title.
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.
*9-11-01* Never Forget; Never Forgive; Never Relent!
"If we ever forget that we're one nation under God, then we will be a nation gone under." - Ronald Reagan
-
September 4th, 2005, 11:55 PM
#4
Re: HTML Title.
 Originally Posted by Dr. Script
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.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 5th, 2005, 06:30 AM
#5
Re: HTML Title.
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.
Code:
$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).
Last edited by bigBA; September 5th, 2005 at 07:38 AM.
there are 10 kinds of people. those who understand binary and those who don't...
rate a post if you find it usefull, thx
check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|