[Li Jingshan php] every day laravel-20161107| phpengine.php

Source: Internet
Author: User
Tags throwable

<?phpnamespace illuminate\view\engines;use exception;use throwable;use symfony\ component\debug\exception\fatalthrowableerror;class phpengine implements engineinterface{//  phpengine implements engineinterface    /**     *  get the evaluated contents of the view.     *      *  @param   string   $path      *   @param   array    $data      *  @return  string      */    public function get ($path,  array $ Data = [])     {        return $ This->evaluatepath ($path,  $data);    }// get the evaluated  Contents of the view.   // evaluate Path    /**     *  Get the evaluated contents of the view at the given path.      *     *  @param   string  $__ path     *  @param   array   $__data      *  @return  string     */    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 ());    }    /**      * handle a view exception.     *     * @ param  \exception   $e      *  @param   int    $obLevel      *  @return  void     *      *  @throws   $e      */     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.}


This article is from the "Focus on PHP Group number: 414194301" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1846652

[Li Jingshan php] every day laravel-20161107| phpengine.php

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.