Php: automatic data type conversion; php: data type conversion _ PHP Tutorial

Source: Internet
Author: User
Php Data type conversion: php Data type conversion. Php Data type conversion: php Data type conversion 1: Overview --- php is a weak type language, it can automatically convert data types according to changes in the runtime environment 1.1 convert php Data types automatically convert, php Data type conversion

1: Overview --- php is a weak language that can automatically convert data types based on changes in the runtime environment

1.1 Principle of converting to a Boolean type

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

A. Boolean type false;

B. empty string''

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

D. array without members ---- array ()

E. null

Other values are converted to true.

1.2 Principle of converting to numeric type

A. If the string is A valid numeric string that does not contain./e/E and does not exceed the storage range of an integer, it is converted to an integer. Otherwise, it is converted to A floating point type;

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

C. convert Boolean true to integer 1 and false to integer 0;

D. convert null to 0

E. round down when the floating point is converted to an integer

1.3 Principle of converting to a string

A. convert the value into A string, that is, the value itself;

B. convert Boolean true to string '1'; convert false to string '';

C. convert null to an empty string '';

D. convert an Array to an Array

E. the resource will be converted to Resourse id # number

Tip 1: overview --- php is a weak language that can automatically convert data types by 1.1 based on changes in the runtime environment...

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.