我想知道相同的是什么:
@include('sidebars.pages')
用普通的PHP?
我尝试过这样的事情:
<?php echo view('sidebars.pages'); ?>
<?php echo view('sidebars.pages')->render(); ?>
<?php echo render('sidebars.pages'); ?>
<?php Blade::compile_string("@include('sidebars.pages')"); ?>
我感谢任何帮助!
答案 0 :(得分:2)
从字面上看,它被翻译成......
<?php echo $__env->make('sidebar.pages', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
因此,在您的尝试列表中,最近的可能是
<?php echo render('sidebar.pages', array_except(get_defined_vars(), array('__data', '__path'))); ?>
参考:View\Compilers\BladeCompiler
/**
* Compile Blade include statements into valid PHP.
*
* @param string $value
* @return string
*/
protected function compileIncludes($value)
{
$pattern = $this->createOpenMatcher('include');
$replace = '$1<?php echo $__env->make$2, array_except(get_defined_vars(), array(\'__data\', \'__path\')))->render(); ?>';
return preg_replace($pattern, $replace, $value);
}
/**
* Get the regular expression for a generic Blade function.
*
* @param string $function
* @return string
*/
public function createOpenMatcher($function)
{
return '/(?<!\w)(\s*)@'.$function.'(\s*\(.*)\)/';
}
答案 1 :(得分:0)
我知道这已经得到了回答,但下列内容是否也有效?
<?php include 'app/views/yourview.php'; ?>