如何处理php中eval函数的解析错误 [英] how to handle parse error for eval function in php
本文介绍了如何处理php中eval函数的解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
但我被困在处理解析错误。
喜欢考虑如果我有边缘案例如1 ..或1 ++
如果给我解析错误:语法错误,.....
<任何人都知道如何处理语法错误或如何绕过错误消息?
我想给出一个更好的错误消息。
也可以将错误消息存储到变量?
TIA
解决方案
$ response = @eval($ string) ;
if(error_get_last()){
echo'显示您的自定义错误消息';
//或者你可以
print_r(error_get_last());
}
I'm trying to use the eval function for php. but I'm stuck in handling the parse error. like considering if I have edge cases like 1.. or 1++ if gives me parse error:syntax error, .....
anyone knows how to handle syntax error or how to bypass the error message? I want to give a better error message.
also is it possible to store the error message to a variable?
TIA
解决方案
$response = @eval($string);
if (error_get_last()){
echo 'Show your custom error message';
//Or you can
print_r(error_get_last());
}
这篇关于如何处理php中eval函数的解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文