[New person] ask all PHPER to run the following code in the workshop and then talk about the feelings.

Source: Internet
Author: User
[New person] ask all PHPER to run the code in the workshop and then talk about your feelings! & Nbsp; $ arrarray (aaa & gt; 123234.232342, dfwee & gt; asdfas2131-safa, drged & gt; 1234, kjyr & gt; 1, bnt & gt; true); & nbsp; & nbsp; & nbsp [new person] ask all phers to run the following code in the samples and talk about their feelings!

$arr=array('aaa'=>"123234.232342",'dfwee'=>"asdfas/2131-safa",'drged'=>1234,'kjyr'=>1,'bnt'=>true);
foreach($arr as $key=>$val){
echo "{$val}==1234 resault is:".($val==1234)." || {$val}===1234 resault is:".($val===1234)."
";
}

Share: More


------ Solution --------------------
I think you're confused about this.
'Bnt '=> true
1 == 1234 resault is: 1
------ Solution --------------------
1 === 1234 resault is:

Only true is displayed as 1.
True = 1234 resault is: 1
------ Solution --------------------
True === 1234 resault is:
Is it clear?
1234 is a non-null value. it is logical (true), so is: 1
True = 1234 at the same time, check whether the data types are consistent. Obviously, a logical type and a numeric type are inconsistent, so it is:

During output, true is printed as 1 and false is printed as null.

------ Solution --------------------
Because php is weak, and the weak type is closer to the natural language
What's more, you need to convert the data type from the source. don't you bother?

------ Solution --------------------
Is there any array_search in your code? why is it so miserable?
------ Solution --------------------
It is strange that most of the array data comes from databases or files. Naturally, each element has the same data type.
No need to judge the type?

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.