What are the different ways where we can use object operators ->
in PHP?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Call a function:
Access a property:
where
$foo
is an instantiated object.PHP has two object operators.
The first,
->
, is used when you want to call a method on an instance or access an instance property.The second,
::
, is used when you want to call astatic
method, access astatic
variable, or call a parent class's version of a method within a child class.When accessing a method or a property of an instantiated class
It is used when referring to the attributes of an instantiated object. e.g: