Home>Article>Backend Development> Master the solution of die() function in PHP

Master the solution of die() function in PHP

autoload
autoload Original
2021-04-23 11:05:33 2424browse

Master the solution of die() function in PHP

Generally during the debugging process, we often use theexit()function,die()This function is still used relatively rarely Yes, in fact, thePHPofficial manual also states that thedie()function is equivalent to theexit()function. This article will take you to take a look.

First let’s take a look at the syntax of the possibleexit()function

die($message)
  • $message: can be returned by a program Value, a string, you can also enter no parameters

  • Return value: If $message is a string, the function will output the string before exiting. $message is an integer and this parameter will not be output. This value will be used as the exit status. The exit status value is between 0 and 254. Exit status 255 is reserved by PHP and will not be used. Status 0 is used to successfully terminate the program

1. The parameter is an integer (generally use theexit()function )

echo "php.cn"; exit(0);

2. The parameter is a string

$fp=fopen("./ok.txt","r") or die("不能打开该文件");

if the file fails to be opened

输出:不能打开该文件

Recommendation:2021 PHP interview questions summary (collection)》《php video tutorial

The above is the detailed content of Master the solution of die() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

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