PHP value inside Javascript variable

I have set PHP variable inside PHP like $geouser. As I need to use this name inside Javascript, can be used the same name and its value inside Javascript? Need help if this will work.

$geouser

An example:

const names =["geouser"];

or I need to use hidden element:

<input type="hidden" id="geouser" name="geouser" />
<script>
var geouser = <?=$geouser?>;
</script>

will assign the value of the PHP variable to a JS variable of the same name.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.