Search the Community
Showing results for tags 'language'.
-
Can I rely on the $_SERVER variable of HTTP_ACCEPT_LANGUAGE to get the language of the browser? I know that some browsers don't send things the same way, and even some servers may not use all variables. Is this the most common way to determine the user's language? Is there another or more preferred way? Thank you.
- 1 reply
-
- internationalization
- browser
-
(and 2 more)
Tagged with:
-
I have included language file and function file in my index.php include 'includes/functions.php'; include 'languages/english.php'; english.php contains <?php $lang['success']['a'] = 'Settings have been updated.'; $lang['error']['b'] = 'Database error. Please try again later!'; ................................. ?> functions.php <?php function testFunction($id, $settings, $db){ $query = 'UPDATE table_name SET a = a + :a WHERE id = :id'; $update = $db->prepare($query); $update->bindParam(':a', $settings['a'], PDO::PARAM_INT); $update->bindParam(':id', $id, PDO::PARAM_INT); $success = $update->execute(); if($success){ print $lang['success']['a']; }else{ print $lang['error']['b']; } } ................................................. ?> Now if i print testFunction(); i got Undefined variable: lang in ............. If i include 'languages/english.php'; in testFunction() then everything works. Any other way to make $lang working without including language file in testFunction(). (Sorry for my bad english) print testfunction(2, $settings, $db);