944,082 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 320
  • PHP RSS
Nov 3rd, 2009
0

Parse Error in Class

Expand Post »
I am writing this simple code. I used this class in PHP 10 minutes ago and now when I did it again it gives me this error. I cannot see the difference
PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. class user
  4. {
  5. public $Username;
  6. public $FullName;
  7. public $Password;
  8. public $LoggedIn;
  9. public $JoinDate;
  10.  
  11. public function changePassword($newPass)
  12. {
  13. $this->Password = md5($newPass);
  14. {
  15. }
  16.  
  17. $user = new user();
  18.  
  19. $user->Username = 'Username';
  20. $user->FullName = 'Name';
  21. $user->Password = 'password';
  22.  
  23. echo $user->Username;
  24. echo $user->changePassword($newPass);
  25.  
  26. ?>

This is the error I get:
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\Lessons\Arrays\test.php on line 26

I would really appreicate someones help in this as I am new to OOP in PHP.

Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
abrocketman is offline Offline
16 posts
since Jun 2009
Nov 3rd, 2009
0
Re: Parse Error in Class
Your } for your changePassword function is a {. Also, you don't need to specify public for all of those variables, scope defaults to public.
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: save file xls or txt
Next Thread in PHP Forum Timeline: Age Calculation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC