search
HomeBackend DevelopmentPHP TutorialPHP4 Practical Application Experience (7)_PHP Tutorial
PHP4 Practical Application Experience (7)_PHP TutorialJul 21, 2016 pm 04:04 PM
if-elseauthorFunctionandactualfamilycontrolofstatementsports

Author: Sun Movement

Another control statement that has almost the same function as the "if-else" family control statement is PHP's "switch" statement. It will look like this:


---------------------------------- -----------------------------------------------
switch (Decision variable)
{
case The first condition is correct:
do this!

case The second condition is correct:
do this!

case The third condition is correct:
do this!

... Wait...

}
-------------- -------------------------------------------------- ----------------
We will make this clearer by rewriting the fortune cookie example above using a "switch" statement:

[cookie.php]

--------------------------------------------- -------------------------------------

// The decision variable here is the date selected by the user
switch ($day)
{

// The first case
case "Monday":
$ fortune = "When you can find a way to make everything complicated and exciting, don't make it simple and effective";
break;

// Second case
case "Tuesday" :
$fortune = "Life is the bridge of the game? - You must have used some kind of trick.";
break;
// The third case
case "Wednesday":
$fortune = "What can make a sane person live in this world and never go crazy?";
break;
// The fourth case
case "Thursday":
$fortune = "Don't be crazy, be interesting";
break;
// The fourth case
case "Friday":
$fortune = "Just follow the times, go with the trend, when you get When you upgrade, you will find that type is a devil. ";
break;


// If none of the above conditions are met...
default:
$fortune = "Sorry. , closed on weekends";
break;

}

?>







This is your lucky word for :




----- -------------------------------------------------- --------------------------
There are two important keywords: the keyword "break" is used to break the "switch" statement structure and immediately moves outside the structure block, then runs the line immediately following the block. The "default" keyword is used to execute a statement that is set when the variables passed to "switch" do not match any of the conditions listed in the statement structure.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315995.htmlTechArticleAuthor: Sun Movement Another control statement that has almost the same function as the if-else family control statement is the PHP switch statement. It will look like this: ---------------------------------------------- ----------...
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
如何禁用媒体音量控制弹出窗口[永久]如何禁用媒体音量控制弹出窗口[永久]May 24, 2023 pm 10:50 PM

当您使用相应的快捷键微调音量级别时,屏幕上会出现一个媒体音量控制弹出窗口。这可能很烦人,因此请继续阅读以找出永久禁用媒体音量控制弹出窗口的不同方法。如何禁用媒体音量控制弹出窗口?1.在谷歌浏览器中单击任务栏上的Windows图标,在顶部的搜索栏中键入chrome,然后选择相关搜索结果以启动谷歌浏览器。在地址栏中键入或复制粘贴以下内容,然后按键。Enterchrome://flags在顶部的搜索框中键入媒体密钥,然后在硬件媒体密钥处理下拉列表中选择禁用。现在退出谷歌浏览器应用程序并重新启动它。谷歌

我们公司如何把项目中的2000个if-else彻底干掉的?我们公司如何把项目中的2000个if-else彻底干掉的?Jul 26, 2023 pm 04:29 PM

首先,获取实现通用接口IOrderOutputStrategy的程序集中的所有类型。然后,我们建立一个字典,格式化程序的displayName的名称为key,类型为value。然后从字典中选择格式化程序类型,然后尝试实例化策略对象。

华硕主板与R55600(包括R55600u和5600h)兼容的选择华硕主板与R55600(包括R55600u和5600h)兼容的选择Jan 02, 2024 pm 05:32 PM

R55600搭配华硕哪个主板华硕ROGStrixB550-FGaming主板是一个非常出色的选择。它与Ryzen55600X处理器完美兼容,并提供出色的性能和功能。该主板具备可靠的供电系统,可支持超频,并提供丰富的扩展插槽和端口,满足日常使用和游戏需求。ROGStrixB550-FGaming还配备了高品质的音频解决方案、快速的网络连接和可靠的散热设计,确保系统保持高效稳定。此外,该主板还采用了华丽的ROG风格,配备了华丽的RGB照明效果,为您的计算机增添了视觉享受。总而言之,华硕ROGStri

赛扬g4900与i36100相比哪个更优?(赛扬g4900与i34170相比哪个更优?)赛扬g4900与i36100相比哪个更优?(赛扬g4900与i34170相比哪个更优?)Jan 01, 2024 pm 06:01 PM

赛扬g4900和i36100哪个好当涉及到赛扬G4900和I36100这两款处理器时,毫无疑问,I36100的性能更胜一筹。赛扬处理器通常被视为低端处理器,主要用于廉价笔记本电脑。而I3处理器则主要用于高端处理器,其性能非常出色。不论是玩游戏还是观看视频,使用I3处理器都不会出现任何卡顿情况。因此,如果你有可能,尽量选择购买英特尔I系列处理器,特别是用于台式机,这样你就能畅享网络世界的乐趣了。赛扬G4900T性能怎么样从性能方面来看,奔腾G4900T在频率方面表现出色,相比之前的版本,CPU性能

李未可AR眼镜,让运动一“镜”到底李未可AR眼镜,让运动一“镜”到底May 27, 2023 am 09:07 AM

5月17日,2023中国国际消费电子博览会在青岛国际展会中心拉开帷幕,本届电博会以“智慧融生,数聚未来”为主题,汇聚了300余家企业展示最新技术、研讨最新行业趋势、共觅未来发展商机。展会上,热点科技以智慧家居、电竞及户外露营为主题展示了一系列科技产品,其中李未可智能AR眼镜以其科技感十足的外观吸引了不少观众的关注。外观上,李未可AR眼镜采用了可拆卸式超轻一片式双曲面镜片,具有防眩光、防汗、防指纹的特性,适应在户外多样的光照环境。镜框采用了轻便的TR90塑胶钛材质,依托中国人头围大数据人体工学研究

站起来,不准跪!一根棍子帮机器狗完成“狗”到“人”进化,关键还适应不同品牌的狗站起来,不准跪!一根棍子帮机器狗完成“狗”到“人”进化,关键还适应不同品牌的狗Apr 14, 2023 pm 09:49 PM

有钱了,想买个机器人,是买个四足机器人好呢?还是买个两足机器人好呢?四足机器人像一个宠物,甚至可以真的拉出去遛遛;两足机器人更像一个伙伴,未来可以给你做做家务。似乎各有各的好,是不是难以抉择了?作为成年人,文摘菌的答案当然是:上周,在日本京都举行的2022年IEEE/RSJ智能机器人与系统国际会议(IROS2022)上,来自伍斯特理工学院(WorcesterPolytechnicInstitute,WPI)和上海科技大学的研究人员提出了一种新方案。让四足机器人进化为双足机器人,想四足着地的时候

如何使用Java实现机器人控制如何使用Java实现机器人控制Jun 16, 2023 am 10:36 AM

近年来,机器人技术得到广泛应用,可见其在科技领域中的重要性。而机器人控制也是机器人开发的核心部分之一。使用Java语言实现机器人控制,能够实现快速的机器人控制,也为机器人的进一步发展提供了有力的支持。Java是一种高级语言,由于其良好的跨平台性、高效性和安全性,成为了广泛使用的编程语言。在实现机器人控制方面,它也能够提供很好的支持。首先,需要了解机器人控制的

零零科技推出 8K 运动飞行相机:哈浮飞行相机 X1 PRO 与 X1 PROMAX零零科技推出 8K 运动飞行相机:哈浮飞行相机 X1 PRO 与 X1 PROMAXAug 28, 2024 pm 03:31 PM

飞行相机开创者零零科技宣布推出哈浮飞行相机X1PRO与X1PROMAX,并已于北京时间8月27日凌晨在Indiegogo开启众筹,上线145分钟,众筹金额即突破百万美金,创造了飞行相机新纪录。两款产品作为全球首款也是最先进的飞行运动相机,重新定义了飞行拍摄体验,尤其适合运动爱好者与专业内容创作者。哈浮飞行相机X1PRO和X1PROMAX便携可折叠设计,无需遥控器交互体验。X1PROMAX:1/1.3英寸CMOS传感器,定制7层镜头。8K视频,14档动态范围,107°广角视野。可定制的ND滤镜。X

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!