2014-04-14 2 views
0

글로벌 $ 회사 변수에 대해 나에게 의미가없는 것처럼 보이는 치명적인 오류가 발생했습니다.laravel 치명적 오류

오류 :

Symfony \ Component \ Debug \ Exception \ FatalErrorException 
syntax error, unexpected '=', expecting ',' or ';' 

코드 : 변수에 대한 전역 범위를 선언하는

public function getCreate(){ 
      $view = View::make('account.create'); 
      global $companies = DB::table('homes')->select('Company')->distinct()->get(array()); 
      return $view->with('companies', $companies)->with('home_names', $home_names); 
     } 

답변

0

global 키워드 만 할 수 있습니다 사용. 동일한 명령문에서 해당 변수에 대해 연산자를 동시에 사용할 수 없습니다.

그래서, 대신이 시도 :

global $companies; 
$companies = DB::table('homes')->select('Company')->distinct()->get(array()); 
+0

감사합니다, 작동! –