PHP 中的 exit() 函数

phpprogrammingserver side programming更新于 2025/11/19 10:52:00

exit() 函数打印一条消息并退出当前脚本。

语法

exit(msg)

参数

  • msg − 退出脚本前要写入的消息。

返回

exit() 函数不返回任何内容。

示例

<?php
   $url = "https://www.example.com/";
   fopen($url,"r")
   or exit("Can't connect!");
?>

输出

以下是输出。

Can’t connect!

相关文章