Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Trying to get this code to work, but I keep running into errors. I am fairly new to PHP and doing a project for personal learning. Thank you in advance for any help!

If I cut the following code out it will run fine. The code with the ** is the code that is throwing the error.

[15-Jul-2012 03:10:01 UTC] PHP Parse error: syntax error, unexpected T_VARIABLE in x.php on line 22

var $salt = 'fortesting';
var $userpw = 'testing';
**var $saltpw = $salt . $userpw;**
var $tpw = hash('sha512', $saltpw, false);
share|improve this question
 
Please , don't make stuff up. Get a beginner's book about PHP and read it. –  tereško Jul 15 '12 at 3:35
 
Are you code inside a class? –  Marcio Simao Jul 15 '12 at 3:36
add comment

closed as too localized by tereško, vascowhite, j0k, Enrico Pallazzo, Michael Berkowski Jul 15 '12 at 22:29

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 2 down vote accepted

Seems like this is a part of properties class' declaration.

Well, you can only specify constant value for properties. So you cannot concatenate strings there.

The possible solution would be to initialize the saltpw property in runtinme in class' constuctor, like:

public function __construct()
{
    $this->saltpw = $this->salt . $this->userpw;
}

PS: var is obsolete, you should use private, protected or public instead

share|improve this answer
 
Appreciate the information very much from the responses. Learned I cannot use concatenation in the declaration area for classes! Creation of a constructor fixed it, thanks again! –  Jeremy Jul 15 '12 at 3:42
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.