|
To show Content in accordance with the country in php |
|
|
|
The following script for PHP sends the code of the country and of the language when the navigator requests it. Often, and especially the international webmaster, we have met the need to show a content in accordance with the country and the languages.
In this Workshop of PHP we are going to see a simple code that will allow to know the country of the user and show a different page for every case.
<? php
//it changes pagina.php for the correct file in accordance with the country
if (isset ($pais) && ($pais <> ")) {
$dgo_pais = substr ($pais, 0,5);
} else {
$dgo_pais = substr ($_SERVER ["HTTP_ACCEPT_LANGUAGE"], 0,5);
}
switch ($dgo_pais) {
marry "es-mx":
//if the country is mexico
include ("pagina.php");
break;
marry "es-ar":
//if the country is Argentine
include ("pagina.php");
break;
marry "es-cl":
//if the country is a chili
include ("pagina.php");
break;
marry "es - it sees":
//if the country is venezuela
include ("pagina.php");
break;
marry "pt-br":
//if the country is brasil
include ("pagina.php");
break;
marry "es-co":
//if the country is colombia
include ("pagina.php");
break;
marry "es-ec":
//if the country is an equator
include ("pagina.php");
break;
marry "es-uy":
//if the country is uruguay
include ("pagina.php");
break;
default:
//if it is some another country
include ("pagina.php");
break;
}
?>
He remembers that to change pagina.php for the page of every country, for example, paginates - mexico.php. It is possible to use this script like principal page, so that it is different according to the country.
Aaron Gomez Perez.
http://www.elwey.com/ |