class classname
{
function operation1()
{
}
function operation2($param1, $param2)
{
}
}
2. constructor
12345678910111213
<?php
class classname
{
function __construct($param)
{
echo "Constructor called with parameter ".$param."<br />";
}
}
$a = new classname("First");
$b = new classname("Second");
$c = new classname();
?>
3. class attribute
1234567
class classname
{
public $attribute;
}
$a = new classname();
$a->attribute = "value";
echo $a->attribute;
4. When you use this keyword “final” in front of a function declaration, that function cannot be overridden in any subclasses
5. PHP use “interface” to implement the function of “multi inheritance”
123456789101112
interface Displayable
{
function display();
}
class webPage implements Displayable
{
function display()
{
// ...
}
}