First all i'm new on OOP. Sorry if this is a noob question.
I'm building a multilanguage web site. I'm fetching database values with languga iso's. For eg: index.php?lang=en
if language value is set with $_GET parameter, mysql brings only en values in database. The problem is with my LanguageController.
// LanguageController Class
class LanguageController {
public $lang = "en";
public function __construct() {
return true;
}
public static function detectLang() {
$lang = 'en';
ob_start();
session_start();
if(isset($_GET["lang"])) {
$lang= $_GET["lang"];
$_SESSION["lang"] = $lang;
setcookie("lang", $lang, time() + (3600 * 24 * 30));
}
else {
$lang = 'en';
$_SESSION["lang"] = $lang;
setcookie("lang", $lang, time() + (3600 * 24 * 30));
return true;
}
}
}
I want to pass default $lang parameter for eg 'en'.
If client change language to 'fr', i must start a session. And mysql brings 'fr' language values.
How can i pass my $lang
parameter on my detectLang()
method.
I tried var_dump(LanguageController::detectLang())
It's coming NULL
.
Any help greatly appricated.