Parse error: syntax error, unexpected (T_STRING), expecting variable (T_VARIABLE) [closed]

感情迁移 提交于 2019-12-25 02:29:17

问题


I will be grateful if someone can point out where the error is occurring.

class hotel extends WishDBxyz{ 
 public nomhotel;
 protected idhotel, ile_idile, pays_idpays, chainehotel_idchainehotel, actif ;
} 

Just on second line got the error Parse error: syntax error, unexpected (T_STRING), expecting variable (T_VARIABLE). I'm quite new to Object Oriented PHP and writting one class inheriting another class.


回答1:


Those are variables in php.So add the $ sign:

class hotel extends WishDBxyz{ 
 public $nomhotel;
 protected $idhotel, $ile_idile, $pays_idpays, $chainehotel_idchainehotel, $actif ;
}



回答2:


you are missing the $

public $var;

see http://www.php.net/manual/en/language.oop5.basic.php




回答3:


You are missing $ in variables

class hotel extends WishDBxyz{ 
 public $nomhotel;
 protected $idhotel, $ile_idile, $pays_idpays, $chainehotel_idchainehotel, $actif ;
}



回答4:


From the PHP manual page:

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

So for your case, you'd put something like:

class Hotel extends WishDBxyz{ 
    public $nomhotel;
    protected $idhotel, $ile_idile, $pays_idpays, $chainehotel_idchainehotel, $actif ;
}

For examples on declaring classes, properties, methods, etc., look at the PHP manual.

(As a habit, I usually use UpperCamelCase for the class name)




回答5:


Variable names should be prefixed with $



来源:https://stackoverflow.com/questions/21930748/parse-error-syntax-error-unexpected-t-string-expecting-variable-t-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!