yii\base\View::renderPhpFile PHP Метод

renderPhpFile() публичный Метод

This method treats the view file as a PHP script and includes the file. It extracts the given parameters and makes them available in the view file. The method captures the output of the included view file and returns it as a string. This method should mainly be called by view renderer or View::renderFile.
public renderPhpFile ( string $_file_, array $_params_ = [] ) : string
$_file_ string the view file.
$_params_ array the parameters (name-value pairs) that will be extracted and made available in the view file.
Результат string the rendering result
    public function renderPhpFile($_file_, $_params_ = [])
    {
        ob_start();
        ob_implicit_flush(false);
        extract($_params_, EXTR_OVERWRITE);
        require $_file_;
        return ob_get_clean();
    }

Usage Example

 /**
  * Renders a view file.
  *
  * This method is invoked by [[View]] whenever it tries to render a view.
  * Child classes must implement this method to render the given view file.
  *
  * @param View $view the view object used for rendering the file.
  * @param string $file the view file.
  * @param array $params the parameters to be passed to the view file.
  * @return string the rendering result
  */
 public function render($view, $file, $params)
 {
     $this->encodeParams($params);
     return $view->renderPhpFile($file, $params);
 }
All Usage Examples Of yii\base\View::renderPhpFile