Class
Basic class definitions, plural classes, begin with the keyword class, followed by a class name, followed by a pair of curly braces which enclose the definitions of the properties and methods belonging to the class.
A class name may be validated with the following regex: ^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$; and by avoiding a list of PHP keywords, such as namespace, class, interface, etc.
<?php
class Elephpant {
const HABITAT = 1;
private $weight = 2;
function method() {
/// and more
}
}
?>
See Also
Related
- Readonly
- Class Invasion
- Const
- Class Getter Method
- implements
- Inheritance
- Method
- Class Setter Method
- Trait
- Class Wither Method
- Structure
- Class Interface Trait Enumeration (CITE)
- $this
- Lazy Objects
- Polymorphism
- Promoted Properties
- Existence
- Phptoken
- Reflection
- Undefined
- Base Class
- instance
- is_a()
- Naming Conflict
- Non-static
- Static Constant
- Conditioned Structures
- Enumeration (enum)
- extends
- Extension Method
- Properties
- Record Type
- Struct Type