An IF statement cannot be found for one day.

Source: Internet
Author: User
An IF statement cannot be found for one day. The code is as follows:
If ($ webstate! = "Y" or $ webstate! = "N") {echo "script" alert ('prompt: illegal error! Error Code: State! '); History. back (-1); script "; exit ;}


My idea is: $ is only in two cases: Y and N. If the third case occurs, an error is returned.

Now, if I only need one condition, it will be normal. if I add one OR more conditions, it will be abnormal (an error will be reported whether it is equal to Y OR N .)


Reply to discussion (solution)

My idea is: $ is only in two cases: Y and N. If the third case occurs, an error is returned.

According to your statement, the third case is that it is not Y and not N. It should be "and", not "or ".

Incorrect logical relationship with and

If ($ webstate! = "Y" | $ webstate! = "N "){
//
} Else {
//
}

If ($ webstate! = "Y" and $ webstate! = "N ")
Or
If (! ($ Webstate = "Y" or $ webstate = "N "))

My idea is: $ is only in two cases: Y and N. If the third case occurs, an error is returned.

According to your statement, the third case is that it is not Y and not N. It should be "and", not "or ".



I walked into a dead end by myself. thank you.

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.