PHP if Statements

Discussion in 'PHP' started by Knuttenstein, Aug 5, 2009.

  1. #1
    Hallo, i was wondering what's the technical term of an if statement doing two or more checks?

    (($UserName == 'MyName')
     && ($DB_HashedPassword == $HashedPassword))
    Code (markup):
     
    Knuttenstein, Aug 5, 2009 IP
  2. EverestTech

    EverestTech Well-Known Member

    Messages:
    554
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    140
    #2
    You can use if elseif statment or switch statment
    
    <?php
    
    //if else if statment
    
    $level = $_REQUEST['level'];
    
    if($level == "admin")
    {
    	echo "Admin Level";
    }
    elseif($level == "mod")
    {
    	echo "Mod Section";
    }
    else
    {
    	echo "defualt section";
    }
    
    //switch statements
    
    switch($level)
    {
    	case "admin":
    		echo "Admin Level";
    	break;
    	
    	case "mod":
    		echo "Mod Level";
    	break;
    	
    	default:
    		echo "default level";
    	break;
    }
    
    ?>
    
    PHP:
     
    EverestTech, Aug 5, 2009 IP
  3. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't think there's a technical name. All you're doing is an if with an AND in it.
     
    premiumscripts, Aug 5, 2009 IP
  4. Stylesofts

    Stylesofts Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,

    Well you can do like this:


    if(($test=="") && ($test!=""))
    {
    }


    you can add more than two conditions but you need to put "add" to check those condition..

    Same case is with the OR as well

    Regards,
    Stylesofts Developing Team
     
    Stylesofts, Aug 6, 2009 IP