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

Master the solution of die() function in PHP

autoload
Release: 2023-03-09 12:18:02
Original
2595 people have browsed it

Master the solution of die() function in PHP

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

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

die($message)
Copy after login
  • $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 the exit() function )

 echo "php.cn"; 
 exit(0);
Copy after login

2. The parameter is a string

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

if the file fails to be opened

输出:不能打开该文件
Copy after login

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!

Related labels:
php
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