+ 4

How can i code with both php and javascript

php

13th Aug 2018, 7:47 PM
😎💻Arsham Azami💻😎
😎💻Arsham Azami💻😎 - avatar
2 Réponses
+ 7
It's fine to do as Kaimi writes and should work just fine; this is just additional info. I don't think PHP's place is clear enough here, so note, this code is perfectly acceptable: <html> <head><title>My page</title></head> <body> <script> alert("prewritten content"); <?php echo(" alert('injected from php'); "); ?> </script> </body> </html> My point is, PHP takes a fully-functional web page, scans for PHP tags, and then does stuff exactly there. It sends anything else (that isn't PHP) without changing it. I prefer this pattern so that PHP-generated content ends up in the right places -- like <body> or <head> -- without making the client browser guess.
14th Aug 2018, 5:51 AM
Kirk Schafer
Kirk Schafer - avatar