What's the difference between accessing a class method via -> and via ::?



What's the difference between accessing a class method via -> and via ::?..

Answer / Barkha Rai

In PHP, the `->` operator is used for calling methods on an instance of a class. For example: `$obj->method()`. On the other hand, the `::` operator is used for static methods and function-like properties. It's called as `ClassName::methodName()`, without any object instance.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

Does jwt protect against csrf?

1 Answers  


can anyone explain about stored procedure,Triggers and transaction in php?

2 Answers  


What is the difference between overloading and overriding in php?

1 Answers  


What do you mean range() in php?

1 Answers  


Tell me what is the use of mysql_real_escape_string() function?

1 Answers  


What is session php?

1 Answers  


which institute provide better PHP trainning in delhi? please tell me how much salary can freshers get ? thanku

5 Answers  


How to register a variable in PHP session?

1 Answers  


Write a program in php to print a table of a number?

1 Answers  


What are the advantages of stored procedures, triggers, indexes in php?

1 Answers  


Is the cookies are available on cross domain?

2 Answers  


What are php applications?

1 Answers  


Categories