PHP函数需要类似于die()函数 [英] PHP Function required similar to die() function
本文介绍了PHP函数需要类似于die()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用PHP开发网站.当某些给定条件不成立时,我使用die()函数终止其余的PHP代码执行.但是随着PHP代码的终止,HTML代码也终止了.我想要一个仅终止PHP执行并且不影响HTML的函数.
I am developing a web using PHP. When some of the given condition is not true, I use die() function to terminate the rest of the PHP code execution. But with the termination of the PHP code, the HTML code is also terminated. I want such a function that only terminate the PHP execution and does not effect the HTML.
推荐答案
您可以使用exit
.看看这个链接:
http://php.net/manual/en/function.exit.php [ ^ ]
祝你好运!
You could useexit
. Have a look at this link:
http://php.net/manual/en/function.exit.php[^]
Good luck!
使用try catch然后将异常抛出为html
Use try catch then throw the exception as html
<html>
<head><title></title></head>
<body>
<?php
echo "Let me see If I can connect to the database.....";
try
{
myObj = 新 MyDbWrapper(); span>
myObj= new MyDbWrapper();
这篇关于PHP函数需要类似于die()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文