PHP Syntax OOP Classes Components Methods Custom Declaring


- Info:

- Methods are declared in the same way as functions, using identical syntax.

- The only difference is that they are typically prefaced with a scope descriptor.


- Example:

- This example shows how to declare Method.

- Creat PHP Console Application Test.php.




class Employee {

private $name;

public function getName() { return $this->name; }

public function setName($name) { $this->name = $name; }