Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial PHP数据类型,真与假?

PHP数据类型,真与假?

Jun 23, 2016 pm 02:26 PM

1.所有的资源类型,都是真?
2.NULL类型,都是假?


回复讨论(解决方案)

所有的空值都视为“假”:0,'0','',false,null,array()....
反之则视为“真”

当转换为 boolean 时,以下值被认为是 FALSE:

布尔值 FALSE 本身
整型值 0(零)
浮点型值 0.0(零)
空字符串,以及字符串 "0"
不包括任何元素的数组
不包括任何成员变量的对象(仅 PHP 4.0 适用)
特殊类型 NULL(包括尚未赋值的变量)
从没有任何标记(tags)的 XML 文档生成的 SimpleXML 对象

所有其它值都被认为是 TRUE( 包括任何资源)。

Statement of this Website
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

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Data type error handling methods in PHP language development Data type error handling methods in PHP language development Jun 10, 2023 pm 07:34 PM

PHP language is a scripting language widely used in web development. In actual development, we often encounter the problem of data type errors. This kind of problem will not only cause the program to fail, but also affect the security of the program. Therefore, we need to learn how to correctly handle data type errors in PHP language development. 1. Understand the data types of PHP language. In PHP language, there are mainly the following data types: Integer type: represents an integer, which can be a positive integer, a negative integer or zero; Floating point type: used to represent real numbers, such as 3.14, -3

The use of data types in PHP The use of data types in PHP May 25, 2023 am 08:52 AM

Data types in PHP are a very important part of programming. In PHP programming, there are various data types that can be used to store different types of values, including numbers, strings, Boolean values, arrays, objects, and null values. Understanding and correctly using these data types is critical to developing efficient and reliable PHP applications. The following are some common PHP data types and their usage: Numbers: PHP uses numbers to store integers and floating point numbers, such as 1, 1.2, etc. Can use math

How to avoid data type conversion errors in PHP language development? How to avoid data type conversion errors in PHP language development? Jun 10, 2023 am 08:48 AM

As a dynamically typed language, PHP often involves data type conversion operations during development. Data type conversion errors may occur accidentally, causing a series of problems when the program is running. Therefore, this article will introduce data type conversion errors in PHP development and provide some methods to avoid these errors. 1. Common data type conversion errors In PHP development, the most common data type conversion error is to force conversion of strings into numeric types, resulting in results that do not meet expectations. For example: $num=

How to use PHP data types How to use PHP data types Jun 11, 2023 am 10:38 AM

PHP is a powerful programming language that is widely used in web development, server-side programming, and command line interfaces. PHP provides a variety of data types, including basic data types and composite data types, that we can use to store and manipulate data. This article will introduce how to use PHP's data types. 1. Basic data type Integer type The integer type is one of the most common types in PHP. It can be used to represent integers, which can be positive integers, negative integers or zero. Integer types can use int or integer

Share and apply appropriate data type usage rules in PHP code specifications Share and apply appropriate data type usage rules in PHP code specifications Aug 11, 2023 pm 02:09 PM

Title: Appropriate data type usage rules and examples in PHP code specifications Overview: In PHP development, the usage specifications of data types can not only improve the readability and maintainability of the code, but also reduce potential errors and security risks. This article will share some appropriate data type usage rules in PHP code specifications and provide relevant code examples. 1. Use appropriate data type declarations and use correct variable types. In PHP, variable declarations do not need to specify data types, but in order to increase code readability and type safety, it is recommended

How to force data to numeric type in PHP How to force data to numeric type in PHP Mar 08, 2024 pm 03:57 PM

In PHP, we often need to deal with various data types, including strings, floating point numbers, integers, etc. Sometimes, we need to force data to a specific numeric type to ensure data accuracy and consistency. This article will explain how to cast data to numeric types in PHP and provide specific code examples. In PHP, data type conversion can be achieved by casting or using related functions. The following will describe how to cast data to integer and floating point types respectively. Cast data to integer class

Data types in PHP and their uses Data types in PHP and their uses May 11, 2023 pm 03:46 PM

As a popular programming language, PHP supports many different data types. In this article, we will discuss various data types in PHP and their usage. String String is one of the most commonly used data types in PHP. Strings can contain letters, numbers, symbols, spaces, etc. To create a string, simply surround the string with double or single quotes. For example: $name="John";$message='Welc

How to use SESSION and COOKIE to manage and operate data types in PHP How to use SESSION and COOKIE to manage and operate data types in PHP Jul 16, 2023 am 11:33 AM

How to use SESSION and COOKIE in PHP to manage and manipulate data types In PHP, SESSION and COOKIE are commonly used mechanisms for storing and transferring data between the server and the client. Through these two mechanisms, we can easily manage and operate different data types. This article will discuss how to use SESSION and COOKIE in PHP to manage and operate data types respectively, and provide corresponding code examples. 1. Use SESSION to manage and operate data type S

See all articles