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