PHP basic PHP Data type strength

Source: Internet
Author: User

PHP is a very weak type language, or a dynamic type language. In most programming languages, variables can only hold one type of data, and this type must be declared before use, such as C. In PHP, the variable type is determined by the value assigned to the variable.

For example, when we create two variables $totalqty and $totalamount, we determine their initial type, as follows:

$totalqty = 0;

$totalamount = 0.0;

Since we are assigning 0 to $totalqty, then $totalqty is a variable of integer type. Similarly, $TOTALAMOUNTJ is a variable of floating-point type. Strangely enough, we can add the following statement to the script:

$totalamount = ' Hello ';

The type of the variable $totalamount can be of type string. PHP can determine the data type of a variable at any time based on the value stored in the variable.

This ability to transparently change the variable type at any time is very useful.

Keep in mind that PHP will "automatically" get the input data type. Once the variable value is retrieved from the variable, it returns data with the same data type.

 Http://bbs.hexun.com/stock/post_5_9809982_1_d.html

Http://bbs.hexun.com/stock/post_5_9810041_1_d.html

PHP basic PHP Data type strength

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.