• PHP Basics learning via PHP tutorial based on skill development
  • Make practise on Conditional Statement in PHP Language with examples
     

Tutorial of PHP IF ELSE Conditions

A Tutorial of PHP IF ELSE Conditions

When a particular condition evaluates to true then if block PHP coding are executed. If the condition is false then statements in else block gets executed.

		if (condition)
		  //write code if condition is true
		else
		  //code executed if condition is false
	  

Here check a PHP example if a value of marks variable is greater than 40 than if block get executed otherwise else will be excuted.

		if ($marks>40)
		  echo"Congreates! You passed in examination, Collect your certificate."
		else
		  echo "Sorry! Try Exam next time";
		

The if-elseif-else Statement

If you have multiple conditions to be excuted then you can use multiple 'else if' block between IF block end ELSE block in your PHP prograaming script. Let’s look at an example:


		<?php
			 $var=27;
			 if($var < 20) {
				  echo "Value is Less than 20";
			 } 
			 else if($var < 40) {
				  echo "Value is Less than 40";
			 }
			 else {
				  echo "Variable value is is Greater than 40";
			 }
		?>


	  

Here Ouput will be "Value is Less than 40";

Software Training & Solution Provider
258,katewa nagar,Gurjar ki thadi,jaipur.
Ph: 9829708506 , 0141-4108506 , 08432830240, 8432706556

09829708506 , 08432830240