Home>Article>Backend Development> php syntax error capture

php syntax error capture

王林
王林 Original
2019-10-10 11:50:24 3365browse

php syntax error capture

PHP syntax error capture processing

Generally, the method used to capture errors is:

try{   ... }catch(Exception $e){   echo $e->getMessage(); }

or

set_exception_handler(function ($exception) {   echo $exception->getMessage(); });

Example:

'; echo $exception->getMessage();//参数错误 }); test(); }catch(Exception $e){ echo $e->getMessage();//参数错误 }

set_exception_handler— Set a user-defined exception handling function for exceptions that are not caught with try/catch blocks.

Recommended tutorial:PHP video tutorial

The above is the detailed content of php syntax error capture. 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