Home > php教程 > PHP源码 > 新手初学PHP随机显示指定文本例程

新手初学PHP随机显示指定文本例程

PHP中文网
Release: 2016-05-25 17:01:32
Original
1210 people have browsed it

if elseif的多次运用

PHP代码

<?php
function getRand() {
    $a=rand(1,5);
    if ($a==1) {
        echo "今天晴天!";
    }elseif ($a==2) {
        echo "今天大太阳";
    }elseif ($a==3) {
        echo "今天下雨天";
    }elseif ($a==4) {
        echo "今天多云";
    }elseif ($a==5) {
        echo "今天流星雨";
    }
}
?>
Copy after login

                   


Related labels:
php
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template