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 use exit. 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();