Home > Backend Development > PHP Tutorial > Randomly display specified text using if elseif usage

Randomly display specified text using if elseif usage

零下一度
Release: 2023-03-10 19:24:02
Original
1976 people have browsed it

Contents of this section:
Display specified text randomly

LearnphpProgrammingif else## The usage of #if is to use if elseif statement multiple times.

Example:

<?php
/*** 随机显示指定的文本* 
by www.jbxue.com*/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

The above is the detailed content of Randomly display specified text using if elseif usage. For more information, please follow other related articles on the PHP Chinese website!

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