if (with If.. ElseIf. else extended instance) conditional statement, which executes the corresponding statement according to the given condition, is a basic statement
<?php//apply If. ElseIf. Else statement to implement the user login function of enterprise Customer service Management System $username = ' Yiciyun '; $password = ' 123456 '; if (!empty ($_post[' user ") &&!empty ($_post [' pwd ']) { //determine if the user name and password are empty $user =$_post[' user ']; $pwd =$_post[' pwd ']; if ($user! = $username) { //determine if the user name is equal to echo ' User name error '; } ElseIf ($pwd! = $password) { //Determine if the password is equal echo ' password error '; } else { //If both are equal, the output login succeeds echo ' login succeeded ';} } else{ echo ' username or password cannot be empty ';}? >
While loop statement that loops the specified statement according to the conditions that are met until the condition is not met
Do.. The while Loop statement is basically the same as the while loop statement, unlike do: The while statement executes the specified statement once before judging
A For Loop statement that provides a more complex loop mechanism, based on the given condition loop, until the condition is not met
<?php //99 multiplication table for ($i =1; $i <10; $i + +) {for ($j =1; $j <= $i; $j + +) { echo "$i * $j =". $i * $J; echo "\ t"; } echo "<br>";}? >
A Foreach Loop statement that is adept at working with arrays, extracting the keys and values of each cell until the end of the array
<?php//Apply the foreach statement in the loop output array of keys and values $book=array ("7 People" = "ASP Department", "5 people" = "VB Department", "6 people" = "PHP Department", "8 people" and "Java department" "), foreach ($book as $value) { echo" $value <br/> ";} foreach ($book as $key + $value) { echo "$key = + $value <br/>";}? >
Switch condition statement, the switch statement executes one line at a time. No code is executed at the beginning. only if the value in one case statement matches the value of the switch expression, PHP starts executing the statement until the end of the switch's program segment or the first break statement is encountered. If you do not write a break at the end of the statement segment of the case, PHP continues to execute the statement segment in the next case.
<?php //Apply the switch statement to determine the user name and password $username = ' Mr '; $password = ' mrsoft '; switch ($_post[' user ']) {case $ Username: $u = true; break; Case ": echo" user name cannot be empty <br/> "; break; Default:echo "User name error <br/>"; break;} Switch ($_post[' pwd ']) {case $password: $p = true; Case ": echo" password cannot be empty <br/> "; break; Default:echo "Password error <br/>"; break;} if (Isset ($u, $p)) { echo "login successful";}? >
<?php //Apply switch statement to determine today is the day of the Week $week=date ("W"), switch ($week) {case 0:echo "Sunday <br/>"; Case 1:echo "Monday <br/>"; Case 2:echo "Tuesday <br/>"; Case 3:echo "Wednesday <br/>"; Case 4:echo "Thursday <br/>"; Case 5:echo "Friday <br/>"; Case 6:echo "Saturday <br/>"; >