Why does "true" output 1, but "false" output nothing?

Source: Internet
Author: User
Why does "true" output 1, but "false" output nothing? & Lt ;? Php $ a = true; echo & nbsp; "output below & nbsp; true & nbsp; & lt; br & gt;"; echo & nbsp; $ a; echo & nbsp; '& lt; br & gt;'; $ a = false: Why does true output 1, but false does not output anything?


$ A = true;

Echo "output below true
";

Echo $;

Echo'
';

$ A = false;

Echo "output below false
";

Echo $;
?>


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

Output:
Bool (false)

We recommend that you use var_dump () for debugging.
------ Solution --------------------
The author of the language writes this statement. when you write a language one day, "false" outputs 0 and "true" outputs nothing. then someone asks why "false" outputs 0 and "true" outputs nothing.
------ Solution --------------------
Php Boolean values true and false; // echo true; 1 echo false no output content
Like php and c, 0 indicates false; non-0 indicates true;

$ A = 1;

Echo "output below true
";

Echo $;

Echo'
';

$ A = 0;

Echo "output below false
";

Echo $;





------ Solution --------------------
For numeric types, false is indeed 0, and for string, false is null. although the number 0 is equal to the string Null, it cannot be said that bool is 0 After string conversion;

var_dump((int)false);
var_dump((string)false);

------ Solution --------------------
Reference:
The author of the language writes this statement. when you write a language one day, "false" outputs 0 and "true" outputs nothing. then someone asks why "false" outputs 0 and "true" outputs nothing.


..........

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.