Blogger Information
Blog 3
fans 0
comment 0
visits 1421
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP学习>流程控制与运算符
我想买个好耳机
Original
571 people have browsed it

0417记录

//取模 %

$num=1234;

// $num= $num %10; //取个位数

// $num=($num/10) %10; //取十位数

// $num=($num/100)%10; //取百位数

// echo $num;


// echo $num++;  //先执行再计算

// echo ++$num;  //先计算再执行

echo 'a'.'b'.'<br>';//类似+拼接字符串


恒等于判断,数值和数据类型都需要一直

var_dump(10==='10');

太空船

a小于b返回-1   a大于b返回1  a=b返回0

var_dump(a<=>b);


//??null合并运算符  如果当前变量为空,为其初始化值

$password ='124abc';

$password = isset($password) ? $password : 'root';

$password=$password ?? 'root';//简化


去掉大括号   模板语法  if开头:   endif结尾;  == {}

$num=5100;

$payment=$num;

if($num>5000):

     $payment=$num*0.8;

endif;


switch 单值判断 

$name='张三';

switch($name):

    case '李四':

        echo 'woshilisi';

    break;

    case '张三':

        echo 'woshizhangsan';

    break;

    default:

    echo'啥也不是';

endswitch;


循环语句while和for

$num1=1;

while($num1):

    $num1++;

break;

endwhile;

echo $num1.'<br>';


for($i=1;$i<10;$i++):

    echo '第'.$i.'次'.'<br>';

endfor;












Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post