PHP Introductory tutorial operator and control structure process, combined with the example of a detailed analysis of PHP basic assignment, self-increment, comparison, trinocular operator and IF statements, switch statements, for statements and other process control statements using skills. Its code is as follows:
demo1.php
<?php $username = "Chaoyv"; echo "His name is $username!"; $username 2 = "WU"; echo "His name is $username 2!"; echo "<br/>"; echo "His name is". $username 2. ", read who asked June chanting, \ \ \ \ \ \ \ \ \ \ \" "; echo "<br/>"; echo "His name is". $username 2. ", read who asked June chanting, \ t water fell fragrance floating. "; Echo ' His name is $username 2! ';//Cannot parse $username 2?>
demo2.php
<?php $a = 5; $b = 6;//$c = $a + $b,//Echo $c,//$a + = $b;//$a = $a + $b;//echo $a;//$a =++ $b;//$b = $b +1//echo $a; 7//echo $b; 7 $a = $b + +; echo $a; 6 echo $b;//7?>
demo3.php
<?php//$a = 5;//$b = ' 5 ';////on the Web page (True True) is the embodiment of 1, the false embodiment is empty///identity must be the same data type///$a = = = $b Return is a fake, false//Echo! ($a = = = $b); What will this print out? $a = 5; $b = 5; $c = ($a = = $b); echo $c; $d = 8; $e = 7; $f = ($d = = $e); echo $c && $f; echo $c | | $f;? >
demo4.php
<?php $total =; Ternary operator //If the judgment is true, then the whole returns the first string, otherwise the second string $sum = $total >50? ' Success ': ' Failure '; Echo $sum;? >
demo5.php
<?php //In the development process, it is best to expose errors. //$a = 100/0; Warning:pision by zero in C:\AppServ\www\Basic3\Demo5.php on line 2 $a = @ (100/0); echo $a;? >
demo6.php
<?php //if conditional judgment statement $userAge =; The parentheses after the if is a Boolean expression that returns a result of 1 or an empty //{} block statement//if ($userAge >18) {// echo ' success ';/} //If ... otherwise//if ($userAge >18) {// echo ' success ';//}else{// echo ' failure ';/} //Multi -line if ($userAge <18) { Echo ' <18 '; } ElseIf ($userAge <30) { echo ' <25 '; } else{ echo ' through '; }? >
demo7.php
<?php //Multi -line//break exit problem, called Midway exit this condition judgment $weekday = 3; Switch ($weekday) {case 1: echo ' Today Monday '; break; Case 2: echo ' Today Tuesday '; break; Case 3: echo ' Today Wednesday '; break; Case 4: echo ' Today Thursday '; break; Default: echo ' not clear '; }? >
demo8.php
<?php //while Loop //When the expression is false, exit the loop $a = ten; while ($a > 0) { echo $a; $a--; Echo ' <br/> '; }? >
demo9.php
<?php //for for ($a =10; $a >0; $a-) { echo $a; Echo ' <br/> '; }? >
demo10.php
<?php //do while $a = ten; do{ echo $a; Echo ' <br/> '; $a--; } while ($a >0);? >
demo11.php
<?php//for ($i = 0; $i <10; $i + +) {//// in this loop nest an if judgment statement// if ($i ==5) {// break;//Midway Exit Loop// } echo $i. ' <br/> ';//}//for ($i = 0; $i <10; $i + +) {//// in this loop, nest an If judgment statement/ if ($i ==5) {// exit;//exit the entire program// } echo $i. ' <br/> ';//}//echo ' I'll do it '; for ($i = 0; $i <10; $i + +) { //within this loop, nest an if judgment statement if ($i ==5) { continue;//exits the current loop and continues the next loop OK } echo $i. ' <br/> '; }? >