PHP code snippet – How to use variable in javascript file? Subash Chandran 20th November 2021 Leave a Comment <script> var p1 = "success"; </script> <?php echo "<script>document.writeln(p1);</script>"; ?> Curly hair, very fair, please share 🙂Click to share on Twitter (Opens in new window)Click to share on Facebook (Opens in new window)Click to share on Reddit (Opens in new window)Click to share on Telegram (Opens in new window)Click to share on WhatsApp (Opens in new window)Click to email a link to a friend (Opens in new window) Related See also How to make a sigmoid function in Python? Snippets PHP code snippet - How to use variable in javascript file? Change font size A Decrease font size. A Reset font size. A Increase font size.