Mohammad Alipour Mohammad Alipour - 1 year ago 111
PHP Question

What is the difference between $_SERVER['HTTP_REFERER'] and $HTTP_REFERER?

I'm looking in an old script.
I found a code :

ereg($self_name, $HTTP_REFERER)

Can I change that code to the following code?:


or change it to

preg_match("%$self_name%", $HTTP_REFERER)

What is the difference between


//Site name for security checks:
$self_name = '.*';

Answer Source

ereg and $HTTP_REFERER are both deprecated and shouldn't be used anymore. use

preg_match("%$self_name%", $_SERVER['HTTP_REFERER'])`

Note that :


only checks if refere is set or not But

preg_match("%$self_name%", $HTTP_REFERER)

check that refere is in $self_name or not

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download