我有一个简单的方法在我的一个对象:
public function action_buddy($name = 'buddy')
{
$this->response->body = View::forge('hello', array(
'name' => $name,
));
}
但是我总是得到这个警告,不能继续:
FuelCore phperroreexception [Warning]:创建默认对象from空值
从这行开始:
$this->response->body = View::forge('hello', array(
如何修复此警告?
注。我遵循这个教程http://code.tutsplus.com/tutorials/getting-started-with-the-fuel-php-framework--net-21334
你使用的教程真的很老了,很多用户也问了这个问题。不管怎样,我来回答你的问题:
return View::forge('hello', array(
'name' => $name,
));
或
// create the layout view
$view = View::forge('hello');
//local view variables, lazy rendering
$view->name = $name;
// return the view object to the Request
return $view;
不要忘记你的燃料/app/config/routes.php请注释
//'hello(/:name)?' => array('welcome/hello', 'name' => 'hello'),
如果你厌倦了那个教程,试试这个
http://ucf.github.io/fuelphp-crash-course/+1关于你的问题,享受Fuelphp!