Why is true output 1, but false but nothing output?

Source: Internet
Author: User
Why is true output 1, but false but nothing output it?


$a =true;


";

echo $a;

Echo '
';

$a =false;


";

echo $a;
?>


If it turns out to be 1 output, then the false should be converted to 0 output.
------Solution--------------------
According to its rules, this is programming.
------Solution--------------------
$a = false;
Var_dump ($a);

Output:
BOOL (FALSE)

Recommended for debugging with Var_dump ()
------Solution--------------------
That's what the author of the language wrote, and when you write a language so that false output 0,true nothing output, then someone asked why false output 0, and true nothing output it
------Solution--------------------
The Boolean value of PHP is true and false; echo true; 1 echo false No output content
PHP, like C, 0 means false; not 0 means true;

$a = 1;


";

echo $a;

Echo '
';

$a = 0;


";

echo $a;





------Solution--------------------
For numeric types, false is really 0, and for string, False is empty, although 0 of the number equals the null of the string, but it cannot be said that the bool conversion string is 0;

Var_dump ((int) false);
Var_dump ((string) false);

------Solution--------------------
Citation:
The author of the language wrote that, and when you write a language to let false output 0,true nothing output, then someone asked why false output 0, and true nothing output it


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