尝试在laravel 5.2中捕获不重定向

时间:2018-07-02 09:43:38

标签: php error-handling laravel-5.2

当应用程序打到API路由且互联网连接不良时,我想显示一条错误消息。我正在Laravel 5.2中做到这一点

<?php

            $jsnsrc = "https://blockchain.info/ticker";
            try{
            $json = file_get_contents($jsnsrc);

            }
            catch(Exception $e){

             return redirect("/error/503");
            }
            $json = json_decode($json);
            $currentBTCvalue = number_format($json->USD->last,2);
            echo $one_BTC_To_USD = $json->USD->last;
            ?>

这仍然行不通

0 个答案:

没有答案