PHP7中的異常處理和錯(cuò)誤處理-創(chuàng)新互聯(lián)

PHP7中異常與錯(cuò)誤處理與之前版本對(duì)比

10年的舒城網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都全網(wǎng)營(yíng)銷(xiāo)推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整舒城建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“舒城網(wǎng)站設(shè)計(jì)”,“舒城網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

先上代碼

ECHO PHP_VERSION.PHP_EOL;
function add (int $left,int $right){
  return $left+$right;
 }
try {
    echo add('left', 'right');
} catch (Exception $e) {
    // Handle exception
} catch (Error $e) { // Clearly a different type of object
    // Log error and end gracefully
    var_dump($e->getMessage());
}
echo PHP_EOL."helloword".PHP_EOL;

PHP v5.6.1結(jié)果

5.6.1
PHP Catchable fatal error:  Argument 1 passed to add() must be an instance of int, string given, called in C:\usertb\shareubuntu\Workerman\fortest.php on line 8 and defined in C:\usertb\shareubuntu\Workerman\fortest.php on line 3
Catchable fatal error: Argument 1 passed to add() must be an instance of int, string given, called in C:\usertb\shareubuntu\Workerman\fortest.php on line 8 and defined in C:\usertb\shareubuntu\Workerman\fortest.php on line 3
[Finished in 0.0s]

PHP v7.0.15結(jié)果

7.0.15-0ubuntu0.16.04.4
string(131) "Argument 1 passed to add() must be of the type integer, string given, called in /home/tb/win10share/Workerman/fortest.php on line 8"
helloword

區(qū)別

在于后者可以捕獲fatal error,并且可以正常輸出helloword

當(dāng)前文章:PHP7中的異常處理和錯(cuò)誤處理-創(chuàng)新互聯(lián)
當(dāng)前網(wǎng)址:http://muchs.cn/article2/dsjcic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、建站公司網(wǎng)站排名、ChatGPT、網(wǎng)站設(shè)計(jì)公司、動(dòng)態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

微信小程序開(kāi)發(fā)