PHP is a weakly typed language
##We noticed that there is no need to ask PHP Declare the data type of the variable.
PHP will automatically convert the variable to the correct data type based on its value. (Recommended learning: PHP video tutorial)
In a strongly typed programming language, we must declare (define) the type and name of the variable before using it. Weakly typed languages are also called weakly typed definition languages. The opposite of strongly typed definitions. Languages such as VB and PHP are weakly typed languages. A weakly typed language is a language with weakly typed definitions. A certain variable has a defined type, and the variable can be automatically converted according to changes in the environment without explicit forced conversion. For example: In vbscript, you can concatenate the string 12 and the integer 3 to get the string 123, and then treat it as the integer 123 without explicit conversion. Weak typing sometimes seems very convenient, but sometimes it is extremely error-prone. For example:var result=5+5; //two numbers alert(result); //outputs "10" var result=5+'5'; // a number and a string alert(result); //outputs "55"
Therefore, when using weakly typed languages, you must also pay special attention to the data type to prevent errors
Whether it is a strongly typed language or a weakly typed language, the fundamental judgment is whether it will Implicit language type conversion. Strongly typed languages are slightly slower than weakly typed languages, but the rigor brought by strongly typed definition languages can avoid unnecessary errors.The above is the detailed content of What type of language is php?. For more information, please follow other related articles on the PHP Chinese website!