Hej!我的问题是下一个。我开始使用Laravel 5.3。我怎样才能做到这一点class
在Laravel:Laravel 5.3 class/routes
class Vehicle
{
public $vehicletype;
function invt($vehicletype){
$this->vehicletype=$vehicletype;
}
function outvt(){
return $this->vehicletype;
}
}
我已经有AJAX .post
,路线:
Route::get('/ajax-vehicletype',function(){
$vehicletypevalue=Input::get('vehicletype');
Vehicle::invt($vehicletypevalue);
});
我得到错误:
Non-static method App\Vehicle::invt() should not be called statically, assuming $this from incompatible context
感谢。
无关,与Laravel,学习OOP静态和非静态方法调用之间的区别:http://php.net/manual/en/language。 oop5.static.php – Devon
你没有定义函数是公共的,私有的,保护的还是静态的 – Phorce