PHP5 introduces Private, Protected, and Public.


Private functions and variables are only visible to members of the current class.

<?php
class cia {
    private $agents = array();

    function remove_secret_ops($agent) {
        return $agent != 'Sterling';
    }

    function get_agents() {
        return array_filter(
            $this->agents, 
            array($this, 
                  'remove_secret_ops')
        );
    }

    function add_agent($name) {
        array_push($this->agents, $name);
    }
}

class cia_administration extends cia {
    function __construct() {
        $this->add_agent('Sterling');
        $this->add_agent('Zeev');
        $this->add_agent('Andi');
        $this->add_agent('Rasmus');
        $this->add_agent('Thies');
    }
}

$cia = new cia_administration;
$pubagents = $cia->get_agents();
$allagents = $cia->agents;

$secretops = array_diff($allagents, 
                        $pubagents);
foreach ($secretops as $sop) {
    echo "$sop is a undercover spy, ";
    echo "let's assasinate him! ";
    echo "Viva la Perl!\n<br />\n";
}
?>
Output