Cetanu Posted October 7, 2009 Share Posted October 7, 2009 Can you use PHP within Javascript? Say I want to make an box pop up containing PHP code (like a form?) can I use alert('') or the other pop up types to do this? >.> Thanks! Quote Link to comment Share on other sites More sharing options...
Mchl Posted October 7, 2009 Share Posted October 7, 2009 PHP is executed on server. JavaScript on the client side (which usually means the browser). So... no... not really. You can however use AJAX to communicate JavaScript in the browser with PHP on the server. Quote Link to comment Share on other sites More sharing options...
Cetanu Posted October 7, 2009 Author Share Posted October 7, 2009 PHP is executed on server. JavaScript on the client side (which usually means the browser). So... no... not really. You can however use AJAX to communicate JavaScript in the browser with PHP on the server. Okay, I'll go look into some AJAX. Thanks. Quote Link to comment Share on other sites More sharing options...
chronister Posted October 7, 2009 Share Posted October 7, 2009 You can actually do this... you would have to use AJAX to make things change, but you can certainly pull data from a database and put it inside javascript code so that when the server loads the page it is there.... <?php // go get data from server.. //all html code and crap here echo '<script>alert("'.$dynamicDataHere.'")</script>'; // ending html crap here ?> That is not to say that it can be changed dynamically with php (without the use of ajax). Quote Link to comment 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.