PHP Hollow String describes the relationship between 0, null, empty, and false

Source: Internet
Author: User
Determine the relationship between 0 and ', null, empty, False
$a = 0;
The relationship between echo "0 and", empty, NULL, false: ";
if ($a = = ") {
echo "0 = ="; ";
}else{
echo "0! ="; ";
}
if (trim ($a) = = ") {
echo "Trim (0) = ="; ";
}else{
echo "Trim (0)! ="; ";
}
if (strval ($a) = = ") {
echo "Strval (0) = ="; ";
}else{
echo "Strval (0)! ="; ";
}
if ($a = = =) {
echo "0 = = ="; ";
}else{
echo "0!=== ';";
}
if (empty ($a)) {
echo "0 is empty;";
}else{
echo "0 is not empty;";
}
if (Is_null ($a)) {
echo "0 is null;";
}else{
echo "0 is not null;";
}
if (Is_numeric ($a)) {
echo "0 is numeric;";
}else{
echo "0 is not numeric;";
}
if (is_string ($a)) {
echo "0 is string;";
}else{
echo "0 is not string;";
}
if (! $a) {
echo "0 is false;";
}else{
echo "0 is not false;";
}
Determine the relationship between ' and 0, null, empty, False
$a = ";
The relationship between echo "' and 0, empty, NULL, false:";
if ($a = = 0) {
echo "' = = 0;";
}else{
echo "'! = 0;";
}
if (intval ($a) = = 0) {
echo "Intval (') = = 0;";
}else{
echo "Intval (')! = 0;";
}
if (empty ($a)) {
echo "is empty;";
}else{
echo "is not empty;";
}
if (Is_null ($a)) {
echo "' is null;";
}else{
echo "is not null;";
}
if (Is_numeric ($a)) {
echo "is numeric;";
}else{
echo "is not numeric;";
}
if (is_string ($a)) {
echo "is string;";
}else{
echo "is not a string;";
}
if (! $a) {
echo "is false;";
}else{
echo "is not false;";
}
Determine the relationship between null and ', 0, empty, false
$a = null;
echo "null and", 0, empty, false the relationship between: ";
if ($a = = ") {
echo "NULL = ="; ";
}else{
echo "Null! ="; ";
}
if ($a = = 0) {
echo "NULL = = 0;";
}else{
echo "Null! = 0;";
}
if ($a = = =) {
echo "NULL = = ="; ";
}else{
echo "null!==="; ";
}
if ($a = = = 0) {
echo "NULL = = 0;";
}else{
echo "null!=== 0;";
}
if (strval ($a) = = ") {
echo "strval (null) = ="; ";
}else{
echo "Strval (NULL)! ="; ";
}
if (intval ($a) = = 0) {
echo "intval (null) = = 0;";
}else{
echo "intval (NULL)! = 0;";
}
if (empty ($a)) {
echo "null is empty;";
}else{
echo "NULL is not empty;";
}
if (Is_numeric ($a)) {
echo "NULL is numeric;";
}else{
echo "NULL is not numeric;";
}
if (is_string ($a)) {
echo "NULL is string;";
}else{
echo "NULL is not string;";
}
if (! $a) {
echo "NULL is false;";
}else{
echo "NULL is not false;";
}
echo "";


The result of the output is:

I think the output can be clear to solve the empty string, 0, null, empty and false between the approximate relationship, in the development process of flexible use of the above code method, coupled with good logic, basically should be no problem.

The above describes the PHP hollow string introduction 0, NULL, empty and false relationship between, including the aspects of the content, I hope to be interested in the PHP tutorial friends helpful.

  • 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.