PHP4实际应用经验篇3
作者:孙运动
在PHP中,最简单的条件语句的形式是 "if" 语句,一般如下所示:
--------------------------------------------------------------------------------
if (条件)
{
do this!
}
--------------------------------------------------------------------------------
这里的 "条件" 是一个条件的描述, PHP经过判断将得出"true"或"false"的任意之一值。如果是真值,所有大括弧里的PHP代码将被执行,相反,如果是假值大括弧里的代码将被忽略,继续执行"if"语句结构块以后的行。
我们通过给上面的 "login.php"脚本添加一个身份认证的例子来给你演示 "if" 语句是如何工作的。只有当用户输入的用户名是"neo"时才允许接入。
--------------------------------------------------------------------------------
// 检查名字并反馈相应的信息
if ($name == "neo")
{
?>
欢迎进入母体,Neo。
也许是武力强迫你才这样做的,,,哦,不正当的影片!
}
?>
//如果密码错了的话
if ($name != "neo")
{
?>
我想知道你是否听说过莎士比亚, .
他要求得到一束另一个名字的玫瑰化,因为那束闻起来可能会更芳香一些。
对于你,很不幸,我不同意。拒绝进入!
}
?>
--------------------------------------------------------------------------------
在这种情况下, "if" 语句通过判断输入的密码是否正确来反馈相应的两种信息。PHP还允许你“嵌套”条件语句-例如,这是一段有效的PHP代码:
--------------------------------------------------------------------------------
if ($day == "Thursday")
{
if ($time == "12")
{
if ($place == "Italy")
{
$lunch = "pasta";
}
}
}
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
