NEWS & UPDATES >> BCA BCSP064 Synopsis & Project Work Started for DEC 2017, IGNOU MCA MCSP060 Synopsis Work Started for DEC 2017, CONTACT 4 IGNOU Mini Project

IGNOU BCA Best Coaching Institute NiPS Provide PHP Q/A



What are the Conditional Statements in PHP

If else statement

The if .. else construct is used to take decision based on the Boolean result that return by a logical expression.

We can use the if ...else block as following examples.

Example 1
if ($val==1)
 {
        echo “The result is 1”;
 }
Example 2
if ($val==’Ram’)
 {
        echo “Your name is Ram”;
 }
else
{
    echo “Your are not Ram”;
}
Example 3
if ($val==’Ram’)
 {
        echo “Your name is Ram”;
 }
else if ($val==’Jo’)
{
    echo “Your name is jo”;
}
else
{
    echo “Name not found”;
}

switch case statement

switch case is the another conditional statement in php.It is used when we need to compare multiple values of a variable. You can use the switch case statement as following.
<?php
    $name="Sijo";
    switch ($name)
    {
    case "Sijo":
      echo "Your name is Sijo";
      break;
    case "Dinson":
      echo "Your name is Dinson";

      break;
    case "Manu":
      echo "Your name is Manu";
      break;
    default:
      echo "Name not faound";
    }
    ?>
Whenever the switch statement is executed,the variable given in the switch statement is evaluated and compared with each case constant. If one of the case constant is equal to the value of the variable given in the switch statement, control is passed to the statement following the matched case label. A break  statement is used to exit the switch statement.If none of the cases match,the default case is invoked.

IGNOU BEST COACHING INSTITUTE IN DELHI NIPS INSTITUTE COLLABORATED WITH IGNOUFRIEND TO PROVIDE FREE SUPPORT AND SOLUTION TO IGNOU BCA MCA STUDENTS

Thanks NiPS Institute for IGNOU BCA MCA Students

No comments:

Post a Comment