javascript - call php var inside JS -
could tell me why not working ?
<html> <body> <?php $var1 = "hello"; echo $var1; ?> <button type="button" onclick="document.getelementbyid('demo').innerhtml = <?php echo(json_encode($var1)); ?>;"> hi</button> <p id="demo"></p> </body> </html>
what should able read php variable js ? thanks
it string. '
s needed added around string.
onclick="document.getelementbyid('demo').innerhtml = '<?php echo(json_encode($var1)); ?>';"
Comments
Post a Comment