欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

php die() 函数使用方法详解

shiping1 的头像

PHP die() 函数

定义和用法

die() 函数输出一条消息,并退出当前脚本。

该函数是 exit() 函数的别名。

语法

die(status)
参数描述
status必需。规定在退出脚本之前写入的消息或状态号。状态号不会被写入输出。

说明

如果 status 是字符串,则该函数会在退出前输出字符串。

如果 status 是整数,这个值会被用作退出状态。退出状态的值在 0 至 254 之间。退出状态 255 由 PHP 保留,不会被使用。状态 0 用于成功地终止程序。

提示和注释

注释:如果 PHP 的版本号大于等于 4.2.0,那么在 status 是整数的情况下,不会输出该参数。

例子

<?php
$site = "http://www.w3school.com.cn/";
fopen($site,"r")
or die("Unable to connect to $site");
?>

来自 http://www.w3school.com.cn/php/func_misc_die.asp





Definition and Usage
定义和用法

The die() function prints a message and exits the current script.
die()函数的作用是:退出当前脚本程序并输出一段信息。

This function is an alias of the exit() function.
die()函数与exit()函数的功能大致相同。

Syntax
语法

die(message)
Parameter参数Description描述
messageRequired. Specifies the message or status number to write before exiting the script. The status number will not be written to the output.
必要参数。在退出脚本程序运行之前指定需要输出的信息和表示状态的数字[status number]。这个状态数字将不会被写入结果中

Example
案例

<?php
$site = "http://www.w3schools.com/";
fopen($site,"r")or
 die("Unable to connect to $site");?> 

来自 http://www.isstudy.com/phpjc/995.html
普通分类: