[英]is it possible in php to use try/catch inside eval
你好 我正在嘗試在 php 里面的 eval() 函數中使用try/catch是可能的嗎?。 我嘗試了一些測試,但沒有捕獲異常。
就是這樣...
eval('
try {
throw new Exception;
} catch(Exception $e) {
var_dump($e);
}
');
該代碼將產生以下輸出...
object(Exception)#1 (7) { ["message":protected]=> string(0) "" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(28) "/in/aqFQZ(3) : eval()'d code" ["line":protected]=> int(3) ["trace":"Exception":private]=> array(1) { [0]=> array(3) { ["file"]=> string(9) "/in/aqFQZ" ["line"]=> int(3) ["function"]=> string(4) "eval" } } ["previous":"Exception":private]=> NULL }
准備好你必須使用 mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.