How to Change a PHP to a JS

When you write JavaScript (JS) code inside of PHP code, you must first escape the PHP code in order for the JS code to execute properly. This changeover from PHP to JS is simple to implement, but can be a frustrating mistake to make if you don't know what to look out for.

Instructions

    • 1

      Open your PHP/JS file in your programming editor of choice.

    • 2

      Locate your JS code that is embedded in your PHP code.

    • 3

      Add a backslash ("\") in front of every set of quotation marks in the Javascript code. Quotation marks are special characters in PHP, and your JS will not execute properly without this change taking place.

    • 4

      Save your PHP file.

Related Searches:

References

Comments

Related Ads

Featured