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. 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... Link to comment https://forums.phpfreaks.com/topic/74420-from-php-into-javascript/#findComment-376048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.