Laravel 控制器没有将变量传递给视图
Laravel controller doesn't pass the variables to view
我看过关于 Laravel 的 youtube 教程。这是代码。我开始学习 Laravel.
<?php
class Authors_Controller extends BaseController {
public $restful = true;
public function get_index(){
$view = View::make('authors.index',array('name'=>'Jedi'))->with('age','18');
$view->location='somewhere';
$view['favorite'] = 'bacon';
return $view;
}
}
?>
查看代码
<?
php echo $name;
echo $age;
echo $location;
echo $favorite;
?>
一旦我 运行 本地主机,我收到一个错误,指出变量未定义。
试试这个..
<?php
class Authors_Controller extends BaseController {
public $restful = true;
public function get_index(){
$view = View::make('authors.index',array('name'=>'Jedi'))->with('age','18');
$view->location='somewhere';
$view['favorite'] = 'bacon';
return View::make('foldername/filename')->with('view',$view);
}
}
?>
我看过关于 Laravel 的 youtube 教程。这是代码。我开始学习 Laravel.
<?php
class Authors_Controller extends BaseController {
public $restful = true;
public function get_index(){
$view = View::make('authors.index',array('name'=>'Jedi'))->with('age','18');
$view->location='somewhere';
$view['favorite'] = 'bacon';
return $view;
}
}
?>
查看代码
<?
php echo $name;
echo $age;
echo $location;
echo $favorite;
?>
一旦我 运行 本地主机,我收到一个错误,指出变量未定义。
试试这个..
<?php
class Authors_Controller extends BaseController {
public $restful = true;
public function get_index(){
$view = View::make('authors.index',array('name'=>'Jedi'))->with('age','18');
$view->location='somewhere';
$view['favorite'] = 'bacon';
return View::make('foldername/filename')->with('view',$view);
}
}
?>