Why is the output of null subtraction null 0?

Source: Internet
Author: User
Why is the output of null subtraction null 0? There is a table uuu with only one data entry, as shown below:

$ Aaa = false; query statement: 'select * from uuu where id = '. $ aaa

Whether the query returns false, '', or null, or what?
I tried this:
$ K = ''-''; $ k = null-null; echo $ k;

All outputs are 0.


Reply to discussion (solution)

$ Aaa = false;

$ SQL = 'select * from uuu where id = '. $ aaa;

Var_dump ($ SQL );

False is a null string when connected to a string.

The output is string (27) "select * from uuu where id ="

The preceding SQL mysql syntax failed. Therefore, false is returned, indicating that the query failed.

It depends on the variable value. do not use echo. use var_dump.

Your query command returns an empty record, so it doesn't matter whether it is false, '', or null

When the record set is not empty and the field value is null, all database functions except PDO can return ''(null string)

$ Aaa = false;
Query statement: 'select * from uuu where id = '. $ aaa
Null ??, Cause ?? There are matched IDs = false ??.

$ K = ''-'';
$ K = null-null;
Var_dump ($ k );

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.