Welcome to WebmasterWorld Guest from 54.145.207.36

Forum Moderators: coopster & jatar k

PHP - Get title

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

WebmasterWorld Senior Member 10+ Year Member



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?

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

WebmasterWorld Senior Member 10+ Year Member



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.

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

10+ Year Member



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.
3:04 am on Jul 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not sure if it is full proof, but it seems to be doing the job.
3:07 am on Jul 7, 2002 (gmt 0)

10+ Year Member



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month