Answer
There are two object operators in PHP. The symbols are -> and ::
-> Operator
The object operator -> is used when you have to access an Instance property or call a method just like a dot (.) in other languages. For example, if there is a ‘Students’ class that includes the method ‘Marks’, we access it by creating an object say ‘Student’. In other languages:
Student.Marks();
In PHP, The object operator -> is used for this purpose e.g.
$Student->Marks();
:: or scope resolution operator
:: or scope resolution operator is used when you want to call a static method, variable or a parent class’s version of a method within a child class. It is called scope resolution operator as it is used to refer the scope of some program context or a block e.g. classes, objects, namespace etc.
For example,
class Students
{
function getMarks()
{
return $marks;
}
}
$marks = Students::getMarks();
:: operator is used when the object has not been created until the class functions or variables are accessed outside the scope of the class.
I see you don’t monetize code.blog, don’t waste your traffic, you can earn additional bucks every month with new
monetization method. This is the best adsense alternative for any type of website (they approve all sites), for more
details simply search in gooogle: murgrabia’s tools
LikeLiked by 1 person
Thanks for the valuable info. I’ll definitely go for it if it seems good
LikeLike