<?php
	//Switch Case using class and object.
	class SwitchOop
	{
		function switchInitialize($ch,$a,$b)
		{
			switch($ch)
			{
				case 1:
					echo "The sum of ".$a." and ".$b." is ".($a+$b);
					break;
				case 2:
					echo "The subtraction of ".$a." and ".$b." is ".($a-$b);
					break;
				case 3:
					echo "The multiplication of ".$a." and ".$b." is ".($a*$b);
					break;
				case 4:
					echo "The division of ".$a." and ".$b." is ".($a/$b);
					break;
				default:
					echo "You enter a invalid choice";
					break;
			}
		}
	}
?>
index.php
<?php
	require("SwitchOop.php");
	$obj=new SwitchOop();
	echo $obj->switchInitialize(3,5,3);
?>

Leave a Reply

Your email address will not be published. Required fields are marked *

3 + 11 =