【发布时间】:2014-09-27 15:18:43
【问题描述】:
这是我的示例代码。
class A {
public function foo(){
}
public function bar(){
}
}
class B {
$one;
function here(){
$this->one = new A();
$this->one->foo();
return View::make("route1"); //This is ok, no problems
}
function there(){
$this->one->bar(); //ERROR: Call to a member function bar() on a non-object
}
}
我的路线
Route::get("/one", B@here);
Route::get("/two", B@there);
请这些只是显示一个示例。它不是正确的代码。
当第一个Route被调用的时候就ok了,相应的页面就加载好了。现在单击一个按钮,该按钮现在请求引发错误的第二页...
//在非对象上调用成员函数bar()
原因很明显,我一直在尝试查看 Laravel 是否提供了一种在页面调用之间持久化对象的方法,以及是否有人可以提供帮助。
谢谢
【问题讨论】:
标签: php object laravel controller persistence