In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge that php is a static language, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this php static language article. Let's take a look at it.
Php is a dynamic language. Php is a dynamic, weakly typed scripting language, which determines the data type at run time, and does not need to be declared in advance before using the variable, and the variable is automatically created when assigned the first value; the data type in PHP can be ignored, when assigning a value to a variable, there is no need to consider its type, waiting for the variable to be assigned a certain value before having a certain type.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php is a dynamic language.
Php is a dynamically typed, weakly typed scripting language; there is no need to declare variables in advance, variables are automatically created the first time they are assigned, and when assigning a value to a variable, there is no need to consider its type, until the variable is assigned a certain value.
Therefore, in the calculation of variables, there will be automatic type conversion.
In PHP, automatic type conversion usually occurs when different types of variables are mixed. If the types of variables involved in the operation are different, they need to be converted to the same type first, and then the operation is carried out.
Usually only four scalar types (integer, float, string, boolean) and NULL automatically convert types in the operation. Note that automatic type conversion does not change the type of the variables themselves, only the way they are evaluated.
Although the automatic type conversion is completed automatically by the system, in the mixed operation, the automatic type conversion also needs to follow the direction of increasing the data length to ensure that the accuracy does not decrease. The rules are shown in the following figure.
When Boolean values are involved in the operation, TRUE will be converted to integer type 1 and false will be converted to integer type 0, and then participate in the operation.
When the NULL value is involved in the operation, the NULL value will be converted to integer 0 before the operation.
When the values of type integer and type float participate in the operation, the value of type integer will be converted to type float before the operation.
When string and numeric (integer, float) values participate in the operation, the string type is converted to a number before participating in the operation. The converted number is a numeric string that begins with a string. For example, a numeric string that begins with a string is converted to a value of type integer without a decimal point. Convert the string "123ab" to the integer 123.45, the string "123.45ab" to the floating point 123.45, and the string "abc" to the integer 0 if it has a decimal point.
[example] here is a simple example to demonstrate automatic type conversion in PHP.
Extended knowledge: introduction and difference between dynamic language and static language
A dynamic language (weakly typed language) is a language in which data types are determined at run time. Variables do not need to declare the type before they are used, and the value of the variable is usually the type of the value assigned. Such as Php, Asp, JavaScript, Python, Perl and so on.
$a = 1 * b = "2"; $c = [1min3pr 4]
Static languages (strongly typed languages) are languages in which the data type of a variable can be determined at compile time, and most static languages require a life data type before using a variable. Such as Java, C, C++, C # and so on.
String s = "hello"; / / variables of type String boolean bounded true; / / variables of type boolean int item0; / / variables of type int
Weakly typed languages are languages in which data types can be ignored. In contrast to strongly typed languages, a variable can assign values of different data types. The type of a variable is determined by its context and is more efficient.
A strongly typed language is a language that must force the determination of a data type, and once a variable is specified a data type, it will always be that data type if it is not cast. The type of a variable is determined when it is declared, which is safer.
Difference:
Due to the mandatory declaration of data types in static languages, development tools (IDE) have a strong ability to judge the code. In the implementation of complex business logic and the development of large business systems, as well as those applications with a long declaration cycle, developers can rely on powerful IDE to develop more efficiently and securely.
Dynamic language thinking is unconstrained and can be played at will, putting more energy on the product itself; focus on the realization of business logic, and the thinking process is the realization process.
This is the end of the article on "is php a static language?" Thank you for reading! I believe you all have a certain understanding of "is php a static language?". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.