Home  >  Article  >  Backend Development  >  Android programmers learn PHP development (15)-dowhile-for-goto-function-PhpStorm

Android programmers learn PHP development (15)-dowhile-for-goto-function-PhpStorm

黄舟
黄舟Original
2017-03-15 15:50:231034browse

This article describes the details of Android programmers learning PHP development (15)-dowhile-for-goto-function-PhpStorm. Friends in need can refer to it

<?php
    /**
     * while和do...while的区别
     */
    echo "----------while和do...while的区别----------<br>";
    while (false){
        echo "1<br>";
    }

    do{
        echo "2<br>";
    }while(false);

    /*以上只输出2*/

    /**
     * for的复杂用法
     */
    echo "----------for的复杂用法----------<br>";
    for ($i=0,$j=10; $i<10 || $j>0 ; $i++,$j--){
        echo "i = {$i} , j = {$j} <br>";
    }

    echo "----------for的复杂用法2----------<br>";
    for ($i=1;$i<=9;$i++){
        for ($j=1;$j<=$i;$j++){
            echo "$j x $i = ".($j*$i)."  ";
        }
        echo "<br>";
    }

    /**
     * goto跳转(方便,但是被唾弃的一个命令,不推荐使用)
     */
    echo "----------goto跳转----------<br>";
    echo "1<br>";
    goto biaoji;
    echo "2<br>";
    echo "3<br>";
    biaoji:
    echo "4<br>";

    /**
     * function函数
     * function_exists判断函数是否存在
     */
    echo "----------function函数----------<br>";
    //$jieguo = 0;
    jiafa(1,2);
    if (function_exists("jiafa")){
        echo "存在<br>";
    }else{
        echo "不存在<br>";
    }
    echo $jieguo; // 因为jieguo是局部变量,所以会报错;

    exit( "----------exit()结束脚本----------<br>");
    echo "exit以后的内容不打印";
    /**
     * 下面两个命令,与while和for相关:
     * break退出循环
     * continue直接进入下一次循环
     */

    /**
     * function函数
     */
    function jiafa($yuansu1,$yuansu2){
        echo $yuansu1+$yuansu2;
        $jieguo = $yuansu1+$yuansu2;
        echo "<br>";
    }

The above is the content of Android programmers learning PHP development (15)-dowhile-for-goto-function-PhpStorm. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:
PhpStorm 10.0.1 Chinese cracked version download


Statement:
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