Forum Moderators: coopster

Message Too Old, No Replies

Getting page title

         

asantos

6:17 am on Nov 12, 2006 (gmt 0)

10+ Year Member



Hi,
i need to get the title of an url through php.

Lets supose www.blablabla.com's title is "Welcome to Bla Bla Bla", but the user only enters the URL in the form... i have to somehow get the title.

mcavic

7:09 am on Nov 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The best way is to use CURL [us2.php.net] to retreive the page, and then probably parse out the title using string functions.

asantos

7:36 am on Nov 12, 2006 (gmt 0)

10+ Year Member



i dont have access to the servers config. is there another way around to accomplish this?

coopster

12:53 pm on Nov 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You may be able to grab the file contents using file_get_contents [php.net] and parse the string for the <title> element with a regular expression.

asantos

4:58 pm on Nov 12, 2006 (gmt 0)

10+ Year Member



Thanks.
Just found this code. Works perfectly:
[php.net...]