adspace


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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the current stable version of php?

1135


What is the difference between htmlentities() and htmlspecialchars()?

1105


Explain me is it possible to destroy a cookie?

1040


how to detect a mobile device using php

1179


List some features of php that are deprecated in php7?

1032


hello all, I need some sample placement papers in lion bridge.. can anyone help me?

2182


What sized websites have you worked on in the past?

1098


Write a program using while loop?

1132


Name and explain five of the PHP error constants?

1047


Tell me what kind of things have you done on the social side?

1072


What does $_files means?

1170


Which variable declarations within a class is invalid in php?

1056


What is difference between static and final in php?

1117


How to create a web form?

1121


if you run the app program all vendor open items are cleared but is it possible to reverse the again again open items please tell me the answer

2000