I want to access php variables in javascript, to be able to pass variables between devices (for example user 1 clicks a button and a function is triggered on user 2’s device)
Something like this:
PHP.php:
<?php
$variable = 1;
?>
SCRIPT.js
var jsvar = NaN;
function sendvariable(value)
{
//php variable
$variable = value;
}
function getvariable()
{
//return a php variable
return $variable;
}
function tick()
{
jsvar = getvariable();
}
setInterval(tick,1000);
I tried something like this:
jsvar = '<?php echo $variable; ?>';
but it just outputed it as a string