Classes are data containers which store functions (called methods) and variables (called properties).

Classes are defined with the class declaration:

Class Declaration

<?php 
class Simple {
}
?>
Properties are defined with the var declaration:

Property Declaration

<?php
class Simple {
    var 
$someprop;
}
?>
Methods are defined with the function declaration:

Method Declaration

<?php
class Simple {
    var 
$someprop;

    function 
somemethod ()
    {
        print (
'HALLO!');
    }
}
?>
In order access class properties and methods, you can use the default $this object, which is created alongside every object instance.

$this

<?php
class Simple {
    var 
$someprop;

    function 
somemethod ()
    {
        
$this->someprop 'Irgendwie neeee?';

        print (
'Ja, das ist doch ' $this->someprop);
    }

    function 
anothermethod ()
    {
        
$this->somemethod ();
    }
}
?>
Constructors are methods that have the same name as the class:

Constructors

<?php
class Simple {
    var 
$someprop;

    function 
Simple () 
    {
        
$this->someprop get_defined_functions ();
    }

    function 
somemethod ()
    {
        
$this->someprop 'Irgendwie neeee?';

        print (
'Ja, das ist doch ' $this->someprop);
    }

    function 
anothermethod ()
    {
        
$this->somemethod ();
    }
}
?>