jimfog Posted April 19, 2013 Share Posted April 19, 2013 I have a created a class where in it you will find password hashing/checking functions...for example: public static function hash($password) { return crypt($password,self::$algo.self::$cost .'$'.self::unique_salt());} And this is the code where you apply the function to a password submitted by the user with a form: $pass_hashed = PassHash::hash($_POST['password']); My question is why the code below is wrong-according to Netbeans IDE? $pass_hashed = PassHash->hash($_POST['password']); Since I am accessing the has function OUTSIDE the class why it is wrong. PassHash is the name of the class. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 19, 2013 Share Posted April 19, 2013 If it's a static method then you use :: to access it. You only use -> when you are access a method of an instantiated object, not a static class method. http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php Link to comment Share on other sites More sharing options...
thescientist Posted April 20, 2013 Share Posted April 20, 2013 see example 2http://php.net/manual/en/language.oop5.static.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now