How to use and or in If-Else in PHP

Introduction

When we need to check more than one condition in if-else, then we use “And” and “OR” operator in if else.

And operator in php

When we need that all condition must be true then we use “And” operator.

For Example

Let’s take the previous example where we calculate gross salary. I am taking the same example here but with some changes. If candidate salary is greater than 10000 and his dept is hr then his pf will be 5% but for other dept the pf will be 2% with all salary.

In this example salary is 6000 and dept is hr. as I told that when we use “And” in if else then all condition must be true. so it comes in else part as both condition are not true and it calculate pf 2% and show the gross.

Use of “OR”

As we know that when we use “And” then all condition must be true similarly in “OR” only one condition need to be true.