Home > Article > Backend Development > What is the difference between js and php
The difference between js and php is: 1. The core functions in php are implemented using functions, while js is implemented using objects; 2. The value-passing and address-passing of variables in js are based on It is determined by the type of object passed, and all types in PHP can freely control whether they pass by value or by address.
[Related learning recommendations: php programming (video)]
js and php The difference is:
1. The core functions of the two are different:
The core function in php is implemented in a functional way, for example, getting the length of a string: $length = strlen(str);
And js is implemented using object methods, such as getting the length of a string: var length = str.length.
2. Variable value transfer methods are different:
In js, the value transfer and address transfer of variables are determined according to the type of the object being passed, and cannot be controlled by oneself;
All types in PHP can freely control whether they are passed by value or by address. Adding & before the variable can become the address method, and not adding & can be the value method.
[Related learning recommendations: js video tutorial]
3. The basic characteristics of the two are different:
php is a general-purpose open source scripting language. The syntax absorbs the characteristics of C language, Java and Perl, which is easy to learn and widely used. It is mainly suitable for the field of Web development.
js is a network scripting language that has been widely used in Web application development. It is often used to add various dynamic functions to web pages to provide users with smoother and more beautiful browsing effects. Usually JavaScript scripts realize their functions by embedding them in HTML.
Related learning recommendations: Programming video
The above is the detailed content of What is the difference between js and php. For more information, please follow other related articles on the PHP Chinese website!