RE: [PHP] getting page title using PHP

From: Date: Wed, 11 Jun 2003 15:49:19 +0000
Subject: RE: [PHP] getting page title using PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-151094@lists.php.net to get a copy of this message
Tim, Here is a function that we use to retrieve the title of the page function title($filename,$dir) { $loc = "$dir/$filename"; if(@is_file("$loc/$filename")) { $open=fopen("$loc/$filename","r"); while(!feof($open)) { $line=fgets($open,255); $string = $line; while ( ereg( '<title>([^<]*)</title>(.*)', $string, $regs ) ) { $string = $regs[2]; } } return $regs[1]; } } Hth Thank You Brian Paulson Sr. Web Developer Email: Bpaulson@Chieftain.com Phone: 1-800-279-6397 Fax: 1-719-544-0264 URL: www.chieftain.com ------------------------------------------- -----Original Message----- From: Tim Thorburn [mailto:immortal@nwconx.net] Sent: Tuesday, June 10, 2003 7:03 PM To: php-general@lists.php.net Subject: [PHP] getting page title using PHP Hi, As a matter of curiosity I've created a little script that will check what screen resolution visitors to my site are using and store the information into a MySQL database. So far, I'm recording the users IP address, screen resolution, and the date/time they visited. Now I'd like to be able to use this same script for all my pages - but I don't want to have to add in a page title each time I want to use the script, nor do I want to make page titles in PHP for all my pages. Is there a command in PHP that can get what's between the <title> and </title> tags? I found a few scripts that can get page titles if they are given a URL to go seek - but these scripts seem to store most of the pages HTML code in memory and I don't think my web host would enjoy that. TIA -Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#151094) next »