here's a simple example where i depending on the sites url it changes $lang which can be used elsewhere or just skipped/replaced with $ccontent, the main objective is that depending on the url it will choose which .php file it will draw its content and variables from.
However i am warned by netbeans not to use superglobals in an array or similar but i still need to get the information and i need to use more superglobals information in the future so i would like to know how i can filter or use them better especially since i want to prevent vulnearabilities & errors cuased by simple misunderstandings so i hope someone can give me a how-to & why-not explanation ☺
Kode: Vælg alt
<?php
switch ($_SERVER["REQUEST_URI"]) {
case "/test/dk/.php":
$Lang = "dk";
break;
case "/test/de.php":
$Lang = "de";
break;
default:
$Lang "en";
}
switch ($lang"]) {
case "dk":
$CContent = "DK-Content.php";
break;
case "de":
$CContent = "DE-Content.php";
break;
case "en":
$CContent = "EN-Content.php";
break;
default:
$CContent "EN-Content.php";
}
include '$CContent';
?>
Kode: Vælg alt
function currentPageURL() {
$curpageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
$curpageURL.= "s";
}
$curpageURL.= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$curpageURL.= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
}
else {
$curpageURL.= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $curpageURL;
}
$Current_URL = currentPageURL();