Home > Backend Development > PHP Problem > How to use die function in php

How to use die function in php

王林
Release: 2023-03-10 13:50:01
Original
2464 people have browsed it

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)
Copy after login

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 = "//m.sbmmt.com/";
fopen($site,"r")
or die("Unable to connect to $site");
?>
Copy after login

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!

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