echo “Welcome, visitor! We couldn’t find your country code!” ;
echo “Welcome, visitor! Your country code is: “ . SimpleGeoTarget::getRegion();
Now, if Jaimie from the United States loaded this script, he would get the output shown in
Figure 11-5. If Cristian loaded the same script, he would get the output shown in Figure 11-6.
In this exercise you presented different output depending on the country the visitor is from. Another popu-
lar use of geo-targeting involves redirecting visitors to localized web sites depending on their region. This
example is analogous to the example of Google’s practice of redirecting visitors from foreign countries from
to their respective local version of Google.
Note that when loading the script from your local machine, your IP is 127.0.0.1, which
doesn’t belong to any country — so the message you’d get is “Welcome, visitor! We
couldn’t find your country code!” To test your region, you need to supply your net-
work IP address as the second parameter of
, or as
the first parameter to
Chapter 11: Cloaking, Geo-Targeting, and IP Delivery
c11.qxd:c11 11:01 240