noahwilson Posted May 9, 2013 Share Posted May 9, 2013 Hello Gusy,<script> var id=`$`php; </script> i have add php variable store as JavaScript. but some thing wrong in my code. what wrong with there please help me . Thanks Link to comment https://forums.phpfreaks.com/topic/277829-how-to-php-variable-value-assign-as-java-script/ Share on other sites More sharing options...
PravinS Posted May 9, 2013 Share Posted May 9, 2013 Use like this <script language="javascript" type="text/javascript"> var id = '<?php echo $id; ?>'; </script> Link to comment https://forums.phpfreaks.com/topic/277829-how-to-php-variable-value-assign-as-java-script/#findComment-1429272 Share on other sites More sharing options...
requinix Posted May 9, 2013 Share Posted May 9, 2013 Even safer is <script type="text/javascript"> var id = <?= json_encode($id) ?>; </script>(language=javascript has been deprecated for a long time) Link to comment https://forums.phpfreaks.com/topic/277829-how-to-php-variable-value-assign-as-java-script/#findComment-1429336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.