Expecting T_FUNCTION



Perhaps you guys can help me. I am getting this error:

 Parse error: syntax error, unexpected 'DEFINE' (T_STRING), expecting function (T_FUNCTION) in

with this code:

public function validatePassword($password, $username){
		return $this->hashPassword($password, $username) === $this->password;
	* @return hashed value
	public function hashPassword($phrase, $salt=null){
		 $key = 'Gf;B&yXL|beJUf-K*PPiU{wf|@9K9j5?d+YW}?VAZOS%e2c -:11ii<}ZM?PO!96';
			if($salt == '')
				$salt = substr(hash('sha512', $key), 0, SALT_LENGTH);
				$salt = substr($salt, 0, SALT_LENGTH);
			return hash('sha512', $salt . $key . $phrase);

Any ideas how to fix this?


Your "DEFINE" should be all lower-case instead of upper-case.

Also, it's good practice to include all your defines, constants, and initializing variables for your class at the top of the class before the first function (I'm assuming these two functions are contained within a class because of your use of "public" scope declarations, otherwise, you don't need them).


Thanks for your reply - I have made it lowercase, and have placed it at the top of the class before my first function and the error is still there unfortunately.

Do you guys have any other ideas?


Since you are using a class, the define should be placed outside of the class.