NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
$_Server['HTTP_REFER']


Joined: 18 Mar 2012
Posts: 3
Reply with quote
How can I get this value? I don't see it in the list.

Thanks
View user's profileFind all posts by richardfrickSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
try to spell this word correctly Smile REFER Smile Smile

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
$_Server['HTTP_REFERER']


Joined: 18 Mar 2012
Posts: 3
Reply with quote
Thanks for the spelling lesson. Let's try again.

How can I get this value? I don't see it in the list.

Thanks,

Richard
View user's profileFind all posts by richardfrickSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Smile you're welcome.
BTW, seems you need one extra try Smile Seriously, add one more R or it'll go further.
Now it's clear why you're interested in code completion... Am I right assuming that what you mean is Code Completion list in the dropdown?
If you mean this, I'm sorry to say that pre-defined constants are not supported in PhpED v6.2. Although it's possible to create a dummy file in the project and have all the indices defined here, like define('HTTP_REFERRER', null);

v7 supports pre-defined constants by default:


_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
When debugging a PHP script, this variable is queried


Joined: 18 Mar 2012
Posts: 3
Reply with quote
Thanks!

I am debugging a PHP script that sets a variable based on this HTTP_REFERER. When I single step using PhpEd this variable is not available.

Is there any way to get this variable?

$refer = substr($_SERVER['HTTP_REFERER'], strrpos($_SERVER['HTTP_REFERER'], '/')+1, -(strpos(strrev($_SERVER['HTTP_REFERER']), '.')+1));
$from = $_POST['Email'];

$refer is always NULL

Thanks, it is the only problem I have encountered with PhpEd.

Great product.
View user's profileFind all posts by richardfrickSend private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
I doubt it is a PhpED problem.

This is the official PHP description for HTTP_REFERER:

Quote:
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.


Is the page that you are debugging activated via a link from another page, so that HTTP_REFERER might actually be set? If you run up the debugger directly on a page, then HTTP_REFERER won't be available. That might also happen for a redirect.

It is good practice to check for the existance of these array elements before using them:

Code:
if (isset($_SERVER['HTTP_REFERER'])) {
    $value = $_SERVER['HTTP_REFERER'];
}


Are you trying to get the name of the referring page? Your code snippet will set $refer to FALSE if HTTP_REFERER does not have a page name with a dot in it (substr returns FALSE if it cannot extract a sub-string).

This might work better:

Code:
if (isset($_SERVER['HTTP_REFERER'])) {
    $refer = substr($_SERVER['HTTP_REFERER'], strrpos($_SERVER['HTTP_REFERER'], '/') + 1);
    if (FALSE !== ($pos = strpos($refer, '.'))) {
        $refer = substr($refer, 0, $pos);
    }
}
View user's profileFind all posts by plugnplaySend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
you may want to check
http://en.wikipedia.org/wiki/HTTP_referer
it explains what you may expect from this thing.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
$_Server['HTTP_REFER']
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic