PHP data type automatic conversion, PHP data type conversion _php Tutorial

Source: Internet
Author: User

PHP data type automatic conversion, PHP data type conversion


1: Overview---PHP is a weakly typed language that can automatically convert data types based on changes in the operating environment

1.1 Principles for converting to Boolean types

The following values are converted to False in the Boolean type:

A. False for Boolean type;

B. Empty string "'

C. Positive 0 or floating-point number 0.0 or string ' 0 ' (excluding string ' 0.0 ')

D. Arrays with no members----Array ()

E.null

In addition, other values are converted to true.

1.2 Principle of conversion into numerical type

A. If the string is a valid numeric string and does not contain./e/e, and does not exceed the range of the integer type, it is converted to an integer type;

B. If the numeric string starts with an illegal character, it is converted to 0;

C. True conversion of Boolean to integer 1,false converted to integer 0;

D.null conversion to 0

E. Rounding down when floating-point numbers are converted to integers

1.3 Principles for converting to strings

A. The numeric value is converted into A string that is the value itself;

B. True conversion of Boolean to string ' 1 '; false to convert to string ';

C.null converted into an empty string ';

D. Array to be converted into array

E. Resources will be converted to Resourse ID #数字

http://www.bkjia.com/PHPjc/1035425.html www.bkjia.com true http://www.bkjia.com/PHPjc/1035425.html techarticle PHP Data type automatic conversion, PHP data type conversion 1: Overview---PHP is a weak type of language, it can be automatically based on the changes in the operating environment of the conversion of data type 1.1 conversion ...

  • Related Article

    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.