SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Expecting T_FUNCTION

    Hey,

    Perhaps you guys can help me. I am getting this error:
    PHP Code:
     Parse errorsyntax errorunexpected 'DEFINE' (T_STRING), expecting function (T_FUNCTIONin 
    with this code:
    PHP Code:
    public function validatePassword($password$username){
            return 
    $this->hashPassword($password$username) === $this->password;
        }
        
    /**
        * @return hashed value
        */
        
    DEFINE('SALT_LENGTH'10);
        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), 0SALT_LENGTH);
                else
                    
    $salt substr($salt0SALT_LENGTH);
                return 
    hash('sha512'$salt $key $phrase);
        } 
    Any ideas how to fix this?

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    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).
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  4. #4
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Since you are using a class, the define should be placed outside of the class.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •