Method
Methods are functions, dedicated to a class. They are defined inside the body of a class, and may only be accessed in relation to that class: via an object, the class name or another method.
Methods are defined in traits, and then imported in a class for usage.
Methods are also called member functions. Indeed, they are functions, but they belong to an object, just like a member, or property. This is less used.
<?php
class Elephpant {
public function trumpet() {
echo "I am trumpet!\n";
}
}
$elephpant = new Y();
$calf->trumpet(); // calling the trumpet method, defined in Elephpant,
?>
See Also
Related
- Class
- __call() Method
- Default Parameter
- Fossilized Methods
- Functions
- Properties
- Return
- Static Method
- Visibility
- Call Graph
- Callbacks
- Impure Function
- Method Compatibility
- Pure Function
- Trait
- Method Collision
- Non-static
- Relay Function
- Function Subscripting
- Generator
- Modifier
- Recursion
- yield from Keyword
- Yield