file: ClassUser.php

<?php
include("ExampleClass.php");
$class_instance = new ExampleClass();
$class_instance->setExample("example sucks");
echo($class_instance->getExample());

$class_instance->NewProperty = "You just created a new propertey of the class, that is not defined per default";
$class_instance->AnotherProperty = "You just created a new propertey of the class, that is not defined per default";

?>

file: ExampleClass.php

<?php
class ExampleClass {
    private $another_var;
    private $example;

    public function __construct($data){
        $this->example = $data;
        $this->another_var = $data;
    }

    public function getExample() {
        return $this->example;
    }

    public function setExample($example) {
        $this->example = $example;
    }

    public function exampleFunction() {
        $test = $this->example; // now that you have a private $example, this will work
        $another_test = $this->another_var; //this obviously does
    }

    /* let's you dynamically generate new properties */
    public function __get($property) {
        if (property_exists($this, $property)) {
            return $this->$property;
        }
    }

    public function __set($property, $value) {
        if (!property_exists($this, $property)) {
            $this->$property = $value;
        }

        return $this;
    }

}
?>

output is:

"$class_instance" (ExampleClass)
-> another_var = 
-> example = example sucks
-> NewProperty = You just created a new propertey of the class, that is not defined per default
-> AnotherProperty = You just created a new propertey of the class, that is not defined per default
admin