PHP Basics-PHP Data type strength

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.