Home  >  Article  >  Backend Development  >  How to use die function in php

How to use die function in php

王林
王林Original
2021-06-10 14:11:182442browse

The die function in php is used to output a message and exit the current script. Its usage is as follows: [die(“unable to connect to xxx”)].

How to use die function in php

The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.

die() function outputs a message and exits the current script.

Function syntax:

die(message)

The message parameter is required and specifies the message or status number to be written before exiting the script. Status numbers are not written to the output.

A simple example:

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

Related video sharing: Programming video

The above is the detailed content of How to use 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