public function hello_everyone()
    {
        return "Hello Everyone<br/>";
    }
    private function hello_me()
    {
        return "Hello Me<br/>";
    }
    protected function hello_family()
    {
        return "Hello Family<br/>";
    }
    // public by default
    function hello()
    {
        $output = $this->hello_everyone();
        $output .= $this->hello_family();
        $output .= $this->hello_me();
        return $output;
    }
}
$example = new Example();
echo "Public a: {$example->a} <br/>";
//echo "Private c: {$example->c} <br/>";
//echo "Protected b: {$example->b} <br/>";
$example->show_abc();
echo "<br/>";
echo "Hello Everyone: {$example->hello_everyone()} <br/>";
//echo "Hello Family: {$example->hello_family()}<br/>";
//echo "Hello Me: {$example->hello_me()}<br/>";
echo $example->hello();
コード例 #2
0
    {
        return "Hello me";
    }
    //public by default
    function hello()
    {
        $output = $this->hello_everyone();
        $output .= $this->hello_family();
        $output .= $this->hello_me();
        return $output;
    }
}
$example = new Example();
echo "public a: {$example->a}<br>";
//Will Return an error by default
//echo "protected b: {$example->b}<br>";
//Will Return an error by default
//echo "private c: {$example->c}<br>";
$example->show_abc();
echo '<br>';
echo "hello everyone: {$example->hello_everyone()}<br>";
echo "<br>";
//Returns an error by default
//echo "hello family: {$example->hello_family()}<br>";
//Returns an error by default
//echo "hello me: {$example->hello_me()}<br>";
//
echo $example->hello();
?>
        </div>
    </div>