A class can have members. The members can be data members and method members. Data members can be private, protected, and public. A private member can only accessed in the class that defines it. A protected member is accessible in the class and its derived class. A public member can be accessed in code outside the class that defines it.
To define a method member, you need to use function keyword.
$emp=new Employee();//create object
$emp->setName();//accessing setName method member
echo $emp->getName();//accessing getName method member
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: