Blogger Information
Blog 17
fans 0
comment 0
visits 11926
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
变量的作用域及流程控制--2018-08-23 17:00
Aken的博客
Original
540 people have browsed it

实例

<?php
/**
 * 变量的类型与检测
 */
$int = 123; //整数
$float = 1.111;  //浮点数型
$str = '字符串';  //字符串型
$bool = true;    //布尔型  真和假

echo gettype($int).'<br/>';
echo gettype($float).'<br/>';
echo gettype($str).'<br/>';
echo gettype($bool).'<br/>';

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<?php
/**
 * 分支结构
 */

//单分支
$a = 100;
if( $a>80 ){
    echo '666'.'<br>';
}

//双分支
if( $a>100 ){
    echo '777'.'<br>';
}else{
    echo '8888'.'<br>';
}

//多分支
$b = 10;
if( $b< 6){
    echo '0','<br>';
}else if($b>=6 && $b<8){
    echo '1','<br>';
}else{
    echo '2','<br>';
}

//三元表达式
echo 1>0 ? '正确':'错误';

echo '<hr>';

//switch
$a = 4;
switch($a){
    case 1:
        echo '1';
        break;
    case 2:
        echo '2';
        break;
    case 3:
        echo '3';
        break;
    default:
        echo '0';
}

运行实例 »

点击 "运行实例" 按钮查看在线实例


QQ图片20180823164259.jpg

Correction status:qualified

Teacher's comments:
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