PHP Type Comparison Table

Source: Internet
Author: User
Tags comparison table

The table below shows the role of PHP types and comparison operators when they are loosely and rigorously compared. The supplemental material is also relevant to the relevant section of the type-juggling. At the same time, a large number of user comments and»blueshoes work also provides help for this material.

Before using these tables, you need to understand the types of variables and their meanings. For example," A" is a string and a whole number is an integer. FALSEis a boolean value and "false" is a string.

Note:

HTML forms do not pass integers, floating-point numbers, or Boolean values, they only pass strings. To detect if a string is not a number, you can use the is_numeric () function.

Note:

When a variable is not defined $x , usage such as if ($x) results in a E_NOTICE level of error. Therefore, you might consider initializing the variable with the empty () or isset () function.

using PHP functions to $x compare variables
An expression GetType () empty () is_null () isset () Boolean: if ($x)
$x = ""; String TRUE FALSE TRUE FALSE
$x = null; Null TRUE TRUE FALSE FALSE
var $x; Null TRUE TRUE FALSE FALSE
$xis undefined Null TRUE TRUE FALSE FALSE
$x = Array (); Array TRUE FALSE TRUE FALSE
$x = false; Boolean TRUE FALSE TRUE FALSE
$x = true; Boolean FALSE FALSE TRUE TRUE
$x = 1; Integer FALSE FALSE TRUE TRUE
$x = 42; Integer FALSE FALSE TRUE TRUE
$x = 0; Integer TRUE FALSE TRUE FALSE
$x =-1; Integer FALSE FALSE TRUE TRUE
$x = "1"; String FALSE FALSE TRUE TRUE
$x = "0"; String TRUE FALSE TRUE FALSE
$x = "1"; String FALSE FALSE TRUE TRUE
$x = "PHP"; String FALSE FALSE TRUE TRUE
$x = "true"; String FALSE FALSE TRUE TRUE
$x = "false"; String FALSE FALSE TRUE TRUE

PHP Type Comparison Table

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.