尊龙凯时人生就是博

thinkphp5.0ÔõÑùÉèÖùýʧҳ

I. ThinkPHP 5.0 ¹ýʧҳµÄ×÷ÓÃ

¹ýʧҳÃæÖ÷ÒªÓÃÓÚ²¶»ñÓ¦ÓóÌÐòÔÚÔËÐÐʱ·ºÆðµÄ¹ýʧ²¢Ìṩ»á¼û¹ýʧÈÕÖ¾µÄÒªÁì¡£

¹ýʧҳÃ滹֧³Öʵʱ¼Í¼¹ýʧÐÅÏ¢ £¬¿ÉÒÔ¿ìËÙÅŲéÏ¢Õù¾öÉú²úÇéÐÎÖеĹýʧ¡£

II. ÉèÖùýʧҳ

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

ÉèÖùýʧҳÃæÐèÒªÔÚÓ¦ÓóÌÐòµÄÉèÖÃÎļþÖоÙÐÐ £¬ÀýÈçÔÚ config.php ÎļþÖÐÔöÌíÒÔÏÂÉèÖãº

'exception_handle'        => 'app\index\exception\Http',

µÇ¼ºó¸´ÖÆ

ÆäÖÐ app\index\exception\Http ÊÇÖ¸Òì³£´¦ÀíÀàËùÔÚµÄÃüÃû¿Õ¼äºÍÀàÃû¡£Òì³£´¦ÀíÀàÐèÒª¼ÌÐø think\exception\Handle Àà £¬²¢ÖØд render ÒªÁìʵÏÖ×Ô½ç˵Òì³£ÐÅÏ¢µÄÊä³ö¡£

III. ¹ýʧҳµÄĬÈÏÉèÖÃ

ThinkPHP 5.0 ÖеÄĬÈϹýʧҳ°üÀ¨ÒÔÏÂÄÚÈÝ£º

Òì³£ÀàÃû

Òì³£¹ýʧÂë

Òì³£¹ýʧÐÎò

Òì³£¹ýʧÎļþ¼°ÐкÅ

Òì³£×·ËÝÐÅÏ¢

ÒÔÉÏÐÅÏ¢¿É×ÊÖú¿ìËÙ¶¨Î»¹ýʧλÖò¢¾ÙÐиú×ÙÆÊÎö¡£³ý´ËÖ®Íâ £¬¹ýʧҳ»¹ÌṩÁ˲Ù×÷°´Å¥ £¬ÒԱ㿪·¢Õß¾ÙÐÐһЩ³£ÓòÙ×÷¡£

IV. ×Ô½ç˵¹ýʧҳ

¹ýʧҳ»¹Ö§³Ö×Ô½ç˵ £¬Ö»ÐèÔÚ¿ØÖÆÆ÷ÖмÌÐø think\exception\Handle Àà £¬²¢ÖØд render ÒªÁì¼´¿É £¬ÀýÈ磺

namespace app\index\exception;

use think\exception\Handle;

class Http extends Handle
{
    public function render(\Exception $e)
    {
        if ($e instanceof HttpException) {
            $status = $e->getStatusCode();
        } else {
            $status = 404;
        }
        $data = [
            'status' => $status,
            'message' => $this->getMessage($e),
            'exception' => $this->isDebug() ? $this->getTrace($e) : [],
        ];
        return json($data);
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂëչʾÁËÔõÑù×Ô½ç˵Òì³£ÐÅÏ¢ £¬ÔÚ±¬·¢¹ýʧʱ·µ»Ø JSON ¹¤Ç©×ÖÌõĹýʧÐÅÏ¢¡£

ÒÔÉϾÍÊÇthinkphp5.0ÔõÑùÉèÖùýʧҳµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ