By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more


How to create a PHP If Or Statement - article explaining how to create Or cases in PHP.

Edited: 2012-04-11 22:00

Sometime you want an If Statement to check for multiple cases, this can be done by using a wrapping parenthesis around the things that you want to check for - each case needs its own wrapping parenthesis.

Let this Article serve as a quick reminder, for those on the road to learning PHP.

Using a wrapping parenthesis

Below shows the wrapping parenthesis method.

if (($a == "a") || ($b == "b")) {
 // The code to be run in case one of the checks returned true.

If it doesn't work

Sometimes people cant get their If Statements to work, simply because they use the wrong operators. Below is a list of Operators, and explanation about what each of them mean.

< Less then
> Greater then
= Equal to
== Exactly Equal to
=== Identical
!= Not Equal to
<= Less then or Equal to
>= Greater then or Equal to

See also

  1. PHP If Then Else and ElseIf Statements