Section 3 - Defining a Class
When you declare a class, you need to list all the variables and all the functions that the object should have - called properties and methods. 3.1.1 shows a class Composition. Note that you can only declare variables or functions within curly braces ({}). 3.1.2 shows how to define three properties and two methods in a class.
3.1.1
class Name extends Another Class
{
Access Variable Declaration
Access Function Declaration
}
3.1.2
//Define a class that tracks users
Class User
{
// Attributes
Public $ name;
PRIVATE $ Password, $ LastLogin;
// Method
Public Function __Construt ORD )
{
$this->name = $name;
$this->password = $password;
$this->lastLogin = time();
$this ->accesses++;
. ; > Print($user->getLastLogin() ."
");
http://www.bkjia.com/PHPjc/445267.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/445267.html
TechArticle