This question is because I have some values in a database table that works as parameters, so the approach I think to use them in javascript without using inline scripts was call a parameters.php
that returns all the values and stores them in javascript global
variables to use them. I just want to know if this is correct or if there is better way how to do this.
That may very well work, but I think it's just as easy to generate inline javascript in the page itself. I assume the parameters may change on each request, so by putting them in the page itself, you save a request for each page view.
Lets think about this - you are sending server variables to a browser
The browser is run by somebody not in your control.
You assume they will send those variables back faithly.
HERE IT BREAKS DOWN.
You receive those variables. AND YOU ASSUME THOSE VARIABLES HAVE NOT BEEN COMPRISED
So those variables go on with you not caring?
You can use something like lets say:
<?php
$variable = "some variable that you need";
?>
<script type="text/JavaScript">
<!--
document.write("<?php echo $variable;?>")
//-->
</script>