develophper
develophper

Reputation: 312

difference between $_SERVER and apache_note

I need to get the user country code and I've managed this by using both

apache_note('GEOIP_COUNTRY_CODE')

and

$_SERVER['GEOIP_COUNTRY_CODE']

Is there any reason why I should use one of these over the other or are they both the exact same? They output the same result and as can be seen have the same index key so I assume it comes from the same place, is this correct?

I tried using the php function geoip_country_code_by_name($_SERVER['REMOTE_ADDR]) but it just returns null (geoip is installed) each time whereas the $_SERVER and apache_note have only not worked when I routed through switzerland.

Upvotes: 1

Views: 735

Answers (1)

insanebits
insanebits

Reputation: 838

It's better practice to use $_SERVER because if your application will scaled you might consider switching to nginx for performance and there apache_note function might not be available while $_SERVER will be available under every server.

From documentation:

The main use for apache_note() is to pass information from one module to another within the same request.

Upvotes: 2

Related Questions