If you have any questions about the basics of php, please give me some advice.

Source: Internet
Author: User
For php basic questions, please give me some advice. Is it wrong? $ C & nbsp; 10; if & nbsp; ($ a & nbsp; & gt; & nbsp; 0) & nbsp; + & nbsp; ($ B & nbsp; & gt; & nbsp; 0) & nbsp; + & nbsp; ($ c & nbsp; & gt; & nbsp; 0) & nbsp; + & nbsp; ($ d & gt; & nbsp; 0) & nbsp ;! & For php basic questions, please give me some advice. Am I wrong?

$ C = 10;
If ($ a> 0) + ($ B> 0) + ($ c> 0) + ($ d> 0 )! = 1 )){
Message ('success ');
} Else
{
Message ('failed ')
}


Excuse me, why does $ c 10 fail to be output in the if statement ?? How can this problem be solved? A, B, and d are all empty. isn't it so understandable ($ c> 0) that c is returned,
C is 10, so c! = 1
Shouldn't the output be successful?
I think this is my misunderstanding. please give me some advice. thank you.
------ Solution --------------------
$ C = 10;
If ($ a> 0) + ($ B> 0) + ($ c> 0) + ($ d> 0 ))! = 1 )){
Message ('success ');
} Else
{
Message ('failed ')
}

------ Solution --------------------
error_reporting(E_ALL ^ E_NOTICE);
$c = 10;
echo ($a > 0) + ($b > 0) + ($c > 0) + ($d> 0);
Output 1
So if ($ a> 0) + ($ B> 0) + ($ c> 0) + ($ d> 0 )! = 1) {not valid (1! = 1)
Therefore, take the else branch
------ Solution --------------------
$ C = 10;
If ($ a> 0) + ($ B> 0) + ($ c> 0) + ($ d> 0 )! = 1 )){

$ A is not defined, so ($ a> 0) false is returned, int type is 0
$ B is not defined, so ($ B> 0) false is returned, int type is 0
$ C = 10, so (10> 0) returns true, where int type is 1.
$ D is not defined, so ($ d> 0) false is returned, int type is 0

After the sentence is repeated, it becomes
If (0 + 0 + 1 + 0 )! = 1 ){

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.