rockinaway Posted October 9, 2011 Share Posted October 9, 2011 Is it possible to use PHP variables in a jQuery file that is including in the header of the file? If so, how? Quote Link to comment https://forums.phpfreaks.com/topic/248755-passing-php-variables-to-jquery/ Share on other sites More sharing options...
awjudd Posted October 9, 2011 Share Posted October 9, 2011 PHP is server side, jQuery is client side. There is no way to directly use the PHP variables in JavaScript. Indirectly, you could do something like this: <script type="text/javascript"> var foo = "<?php echo $superSpecialVariable; ?>"; </script> To assign client-side variables at run time. ~juddster Quote Link to comment https://forums.phpfreaks.com/topic/248755-passing-php-variables-to-jquery/#findComment-1277502 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.