Hi, Based on user's preferences I inject into my application a jason_encoded(translation array) which is later converted to javascript object and used by the application. Which, in your opinion, is the better way to do it?
Solution 1:
<head>
<script type="text/javascript" src="lang.php"></script>
</head>
Solution 2 (code is executed inside index.php):
<head>
<?php
require_once(database_connect.php);
//Prepare $myDictionary...
$dictionary = json_encode($myDictionary);
echo ("
<script type='text/javascript'>
var dictionary=". $dictionary .";
</script>
");
require_once(database_close.php);
?>
</head>
I'am currently using the first solution, because I can cache the results, but I wan't to know if putting all that php code (including require/include functions) inside index.php is good or bad idea. Thanks for any suggestions.