homepage Welcome to WebmasterWorld Guest from 54.226.168.96
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP - Get title
Lisa




msg:1258198
 8:33 pm on Jul 6, 2002 (gmt 0)

I am trying to capture the title of the referer.

$fcontents = implode ('', file ('$HTTP_REFERER'));
$fcontents = stristr($fcontents, '<title>');
$rest = substr($fcontents, 7);
$extra = stristr($fcontents, '</title>');
$titlelen = strlen($rest) - strlen($extra);
$gettitle = trim(substr($rest, 0, $titlelen));
echo "Coming from: " . $gettitle . "<p>";

The code seems buggy, Anyone have suggestions?

 

Lisa




msg:1258199
 2:01 am on Jul 7, 2002 (gmt 0)

Ah, I found the bug, now this is good code!

$fcontents = implode ('', file ("$HTTP_REFERER"));
$fcontents = stristr($fcontents, '<title>');
$rest = substr($fcontents, 7);
$extra = stristr($fcontents, '</title>');
$titlelen = strlen($rest) - strlen($extra);
$gettitle = trim(substr($rest, 0, $titlelen));
echo "Coming from: " . $gettitle . "<p>";

Notice the double quote problem.

Knowles




msg:1258200
 2:03 am on Jul 7, 2002 (gmt 0)

You beat me to it Lisa I was working on it. Course I am not sure I would have figured it out since it was simply the quotes. At least thats the only difference I see. Glad you got it fixed.

Lisa




msg:1258201
 3:04 am on Jul 7, 2002 (gmt 0)

I am not sure if it is full proof, but it seems to be doing the job.

Knowles




msg:1258202
 3:07 am on Jul 7, 2002 (gmt 0)

It worked when I tried it locally. Thats a nice idea I think I might hang on to it maybe Ill find a use for it.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved