PHP is a very weak type language or dynamic type language. In most programming languages, variables can only store one type of data, and this type must be declared before use, such as C language. In PHP, the variable type is determined by the value assigned to the variable.
PHP is a very weak type language or dynamic type language. In most programming languages, variables can only store one type of data, and this type must be declared before use, such as C language. In PHP, the variable type is determined by the value assigned to the variable.
For example, when we create two variables $ totalqty and $ totalamount, their initial types are determined, as shown below:
$ Totalqty = 0;
$ Totalamount = 0.0;
Since we assign 0 to $ totalqty, $ totalqty is an integer variable. Similarly, $ totalamountj is a floating point type variable. It is very strange that we can add the following statements in the script:
$ Totalamount = 'hello ';
$ Totalamount variable type can be string type. PHP can determine the data type of a variable at any time based on the value stored in the variable.
This function is very useful to transparently change the variable type at any time.
Remember, PHP will "automatically" get the input data type. Once a variable value is retrieved from the variable, it returns data of the same data type.
?
Fixed link:PHP learning blog? PHP Basics-PHP Data type strength?
Solemnly declare:This article was published by alexa617, which is original except for the special instructions. all content only represents personal opinions. The copyright belongs to the PHP study Blog and alexa617. You are welcome to reprint it. However, you must keep this statement without the author's consent and provide a link to the article. Otherwise, you will be held legally liable! If this article infringes your rights and interests, leave a message.