Bonjour,
Le code ci-dessous me provoque une erreurFatal error: Uncaught Error: Using $this when not in object context ... on line 18
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 namespace Languages; class Languages { public static function setUserLanguage() { // First priority: User choose a new Language if (isset($_GET['language'])) return $_GET['language']; // 2nd priority: Language were already selected elseif (isset($_SESSION['language'])) return $_SESSION['language']; // 3rd priority: A language were already selected in a previous session elseif (isset($_COOKIE['language'])) return $_COOKIE['language']; else return $this->getMainBrowserLanguage(); } public static function getMainBrowserLanguage() { return \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); } /* handleCookieLanguage save selected language in cookie if days is <0 cookie is deleted if days = 0 previous cookie is held if days >0 cookie is overwrite */ public static function handleCookieLanguage($days) { $holdTime *= 24*3600; if ($days <0) unset($_COOKIE['language']); elseif ($days > 0) setcookie('language',$this->setUserLanguage(),$holdTime); } }
Partager