I have seen that there are two different ways to access methods within a class. Are there any differences in behaviour, or are they purely alternative syntaxes for the same action?
$a = new A();
$a->foo();
A::foo();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t just use one or the other.
::is for static methods and variables, whereas->is for instance methods and variables. This is “inspired” from C++ syntax.or
According to DCoder,
::can be used for calling parent methods, but I don’t know this for sure.