文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Statements

Statements

时间:2008-01-17  来源:xiaoaizhen

Every statement is an expression, optionally followed by a modifier, and terminated by a semicolon. The semicolon may be omitted if the statement is the final one in a BLOCK.

Execution of expressions can depend on other expressions using one of the modifiers if, unless, while or until, for example:

    EXPR1 if EXPR2 ;
    EXPR1 until EXPR2 ;

The logical operators ||, && or ?: also allow conditional execution:

    EXPR1 || EXPR2 ;
    EXPR1 ? EXPR2 : EXPR3 ;

Statements can be combined to form a BLOCK when enclosed in {}. Blocks may be used to control flow:

    if (EXPR) BLOCK [ [ elsif (EXPR) BLOCK ... ] else BLOCK ]
    unless (EXPR) BLOCK [ else BLOCK ]
    [ LABEL: ] while (EXPR) BLOCK [ continue BLOCK ]
    [ LABEL: ] until (EXPR) BLOCK [ continue BLOCK ]
    [ LABEL: ] for (EXPR; EXPR; EXPR) BLOCK
    [ LABEL: ] foreach VAR† (LIST) BLOCK
    [ LABEL: ] BLOCK [ continue BLOCK ]

Program flow can be controlled with:

    goto LABEL Continue execution at the specified label. last [ LABEL ] Immediately exits the loop in question. Skips continue block. next [ LABEL ] Starts the next iteration of the loop. redo [ LABEL ]   Restarts the loop block without evaluating the conditional again.

Special forms are:

    do BLOCK while EXPR ;
    do BLOCK until EXPR ;

which are guaranteed to perform BLOCK once before testing EXPR, and

    do BLOCK

which effectively turns BLOCK into an expression.

相关阅读 更多 +
排行榜 更多 +
宝宝情商养成宝宝巴士

宝宝情商养成宝宝巴士

休闲益智 下载
燥热手机版

燥热手机版

飞行射击 下载
巨人狙击手安卓版

巨人狙击手安卓版

飞行射击 下载