Home >Backend Development >PHP Tutorial >Automatic data type conversion in php, data type conversion in php_PHP tutorial

Automatic data type conversion in php, data type conversion in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:46:18900browse

Automatic conversion of data types in php, data type conversion in php

1: Overview---php is a weakly typed language, which can change according to changes in the running environment Automatically convert data types

1.1 Principles of conversion to Boolean type

The following values ​​will be converted to false in the Boolean type:

A. false of Boolean type;

B. Empty string''

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

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

E.null

Except for this, all other values ​​are converted to true.

1.2 Principle of conversion into numerical value

A. If the string is a legal numeric string, does not contain ./e/E, and does not exceed the storage range of integer, it will be converted to integer type; otherwise, it will be converted to floating point type;

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

C. Boolean true is converted into an integer 1, false is converted into an integer 0;

 D.null is converted to 0

E. Round down when converting floating point numbers into integers

1.3 Principles of converting into string

A. The value is converted into a string, which is the value itself;

B. Boolean true is converted into a string '1'; false is converted into a string '';

C.null is converted into an empty string'';

 D. Convert array to Array

E. The resource will be converted into Resource id #number

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1035425.htmlTechArticleAutomatic conversion of data types in php, data type conversion in php 1: Overview---php is a weak type language, which can automatically convert data types according to changes in the operating environment 1.1 conversion...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn