Home >Backend Development >PHP Problem >Can js be replaced by php?
js cannot be replaced by php.
PHP is a server-side language. After parsed by the server, the html text part is output to the client.
Javascript is a client-side language, that is, it is parsed in the client's browser.
Functionally speaking.
Some parts can be replaced, such as form verification. If you just want to implement form verification, both javascript and PHP can be used for verification, but their verification methods are different. If you use PHP to verify, just It must be submitted, that is, the client and the server must have an interaction, send a request to the server, and then PHP will regenerate a page to the client after verification.
When JavaScript is used for form verification, most requests do not need to be sent (except for those content that requires server verification, such as ajax actions such as whether the user name has been registered).
The other aspect of javascript is the animation implemented in web pages, which PHP can never replace. Because this is running on the client side!
So javascript and PHP are irreplaceable.
The above is the detailed content of Can js be replaced by php?. For more information, please follow other related articles on the PHP Chinese website!