HAN! Posted October 23, 2007 Share Posted October 23, 2007 how to use php variables in javascript, i need the way to transfer php variables into javascript ones and use them in javascript, thanx for any help. Quote Link to comment https://forums.phpfreaks.com/topic/74420-from-php-into-javascript/ Share on other sites More sharing options...
enoyhs Posted October 23, 2007 Share Posted October 23, 2007 One of ways I am aware of is: <?php $phpVar = "Hello world!"; ?> <script type="text/javascript"> var jsVar = '<?php echo $phpVar ?>'; alert(jsVar); </script> There must be several ways but I usually use this when needed... Quote Link to comment https://forums.phpfreaks.com/topic/74420-from-php-into-javascript/#findComment-376048 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.