Why is the empty minus null output 0?

Source: Internet
Author: User
There is a table UUU, with only 1 data, as follows:

$AAA = false; Query statement: ' SELECT * from UUU where id= '. $aaa

Does this query return false, or ', or null, or what?
I tried this:
$k = "-"; $k = Null-null;echo $k;

The output is all 0.


Reply to discussion (solution)

$AAA =false;

$sql = ' SELECT * from UUU where id= '. $aaa;

Var_dump ($sql);

False is an empty string when connected to a string

Output is String ("select * from UUU where id=")

The above SQL MySQL syntax detection does not pass so you return false to indicate that the query failed

To see the value of the variable, do not use echo, use Var_dump

Your query directive returns an empty record, so it doesn't matter if it's false, or ', or null

When the recordset is not empty and the field value is null, except that PDO can be specified, other database functions return "(empty string)

$AAA = false;
Query statement: ' SELECT * from UUU where id= '. $aaa
Return to empty???? There are??。 matching id=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.