栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

PhpEngine.php

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PhpEngine.php

 

namespace IlluminateViewEngines;

 

use Exception;

use Throwable;

use SymfonyComponentDebugExceptionFatalThrowableError;

 

class PhpEngine implements EngineInterface

{// PhpEngine implements EngineInterface

   

    public function get($path, array $data = [])

    {

        return $this->evaluatePath($path, $data);

    }// get the evaluated contents of the view.

   // evaluate Path

 

   

    protected function evaluatePath($__path, $__data)

    {// Get the evaluated contents of the view at the given path

        $obLevel = ob_get_level();// get this ob level

 

        ob_start();// start ob

 

        extract($__data, EXTR_SKIP);// get this data

 

        // We'll evaluate the contents of the view inside a try/catch block so we can

        // flush out any stray output that might get out before an error occurs or

        // an exception is thrown. This prevents any partial views from leaking.

        try {

            include $__path;// try get this file

        } catch (Exception $e) {

            $this->handleViewException($e, $obLevel);// handle

        } catch (Throwable $e) {

            $this->handleViewException(new FatalThrowableError($e), $obLevel);// handle

        }// we'll evaluate the contents of the view inside a try/catch block so we can

       // flush out any stray output that might get out before an error occurs or

       // an exception is thrown. this prevents any partial view from leaking.

 

        return ltrim(ob_get_clean());

    }

 

   

    protected function handleViewException(Exception $e, $obLevel)

    {

        while (ob_get_level() > $obLevel) {

            ob_end_clean();

        }// clean ever thing

 

        throw $e;// throw $e

    }//Handle a view exception.

}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/228610.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号