What is the difference between JS scripting language and PHP scripting language? Bottom line: JS is a client script that is executed by the browser. PHP is a server-side script, which is executed by PHP service. PHP script is quite similar to shell script (bash execution).
Take a look at the JS script and write a test.html file
<script> alert("this is js"); </script>
Double click the local test.html file, and you will get a pop-up box, because the browser executes the above JS script.
Take a look at the PHP script again. Write a test.php file. The content is:
<?php echo "this is php\n"; ?>
Execute on the Linux machine with PHP service, such as / usr / local / PHP / bin / PHP test.php, and you will get the result of this is PHP. (now there are many web tools for online execution of PHP language, which are also very easy to use. In fact, they should be executed by the PHP service in the background.)
In fact, both JS and PHP can be directly surrounded by HTML tags. Therefore, the above test.html and test.php can be changed to:
<html> <body> <script> alert("this is js"); </script> </body> </html>
It is executed by the browser and parses the HTML behavior.
<html> <body> <?php echo "this is php\n"; ?> </body> </html>
Executed by the PHP service, the PHP service generates strings, but cannot parse these HTML. However, you can give these strings to the client browser to parse, and the browser will recognize these HTML tags and parse them.
First of all, it’s easy to understand.
The above is the whole content of this article. I hope that the content of this article has some reference learning value for your study or work. Thank you for your support for developepaer. If you want to know more about it, please check the relevant links below