search
Homephp教程php手册php之数据类型自动转换,php之数据类型转换

php之数据类型自动转换,php之数据类型转换

1:概述 ---php是一种弱类型的语言,它可以根据运行环境的变化而自动进行数据类型的转换

1.1转换成布尔类型的原则

  以下值都将转换成布尔类型中的false:

  A.布尔类型的false;

  B.空字符串''

  C.正数0或浮点数0.0或字符串'0'(不包括字符串'0.0')

  D.没有成员的数组----array()

  E.null

  除此之外其它值都转换成true.

1.2转换成数值型的原则

  A.如果字符串为合法的数字字符串,同时不包含./e/E,而且没有超过整型的存数范围时,将转换为整型;否则转换成浮点型;

  B.如果数字字符串以非法的字符开头,则转换成0;

  C.布尔型的true转换成整数1,false转换成整数0;

  D.null转换为0

  E.浮点数转换成整数时向下取整

1.3转换成字符串的原则

  A.数值转换成字符串即数值本身;

  B.布尔型的true转换成字符串'1';false转换成字符串'';

  C.null转化成空字符串'';

  D.数组转换成Array

  E.资源将转换成Resourse id #数字

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)