Android programmers learn PHP development (10)-Process Control-PhpStorm

黄舟
Release: 2023-03-06 09:56:01
Original
1341 people have browsed it

Process control: sequential structure, branch structure (selection structure), loop structure.

<?php
    /**
     * 流程控制:
     * 顺序结构、分支结构(选择结构)、循环结构
     *
     * 1、分支结构:
     * 1.1、单一条件分支结构(if)
     * 1.2、双向条件分支结构(else)
     * 1.3、多向条件分支结构(elseif、switch)
     * 1.4、巢状条件分支结构
     */

    /**1.1、单一条件分支结构(if)*/
    if (1==1){
        echo "iwanghang Android<br>"; // iwanghang Android
    }

    /**1.2、双向条件分支结构(else)*/
    if (1==1){
        echo "iwanghang xixi<br>"; // iwanghang xixi
    }else{
        echo "iwanghang haha<br>";
    }

    if (1==2){
        echo "iwanghang 666<br>";
    }else{
        echo "iwanghang 777<br>"; // iwanghang 777
    }

    /**1.3、多向条件分支结构(elseif、switch)*/
    $a = 1;
    if ($a==3){
        echo "iwanghang 333<br>";
    }elseif($a==2){
        echo "iwanghang 222<br>";
    }elseif($a==1) {
        echo "iwanghang 111<br>"; // iwanghang 111
    }else{
        echo "a不是1、2、3<br>";
    }

    switch ($a){
        case 3:
            echo "a==3<br>";
            break;
        case 2:
            echo "a==2<br>";
            break;
        case 1:
            echo "a==1<br>"; // a==1
            break;
        default:
            echo "a不是1、2、3<br>";
    }

    $b = 33; // 这里可以尝试给b赋值3、33、333,看一下打印结果
    switch ($b){
        case 3:
        case 33:
        case 333:
            echo "b符合3、33、333其中一种情况<br>"; // b符合3、33、333其中一种情况
            break;
        case 2:
            echo "b==2<br>";
            break;
        case 1:
            echo "b==1<br>";
            break;
        default:
            echo "b不是1、2、3<br>";
    }

    /**1.4、巢状条件分支结构*/
    $name = "iwanghang";
    $sex = "man";
    $age = 18;
    if ($sex == "man"){
        echo "{$name}是老爷们<br>"; // iwanghang是老爷们
        if ($age > 60){
            echo "{$name}退休了".($age-60)."年<br>";
        }else{
            echo "{$name}还有".(60-$age)."年退休<br>"; // iwanghang还有42年退休
        }
    }else{
        echo "{$name}是老娘们<br>";
    }
Copy after login

The above is the content of Android programmers learning PHP development (10)-Process Control-PhpStorm. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template