コード例 #1
0
ファイル: oo3.php プロジェクト: anatai/manray
<?php

class person
{
    //this is a container for functions and variables that share the same scope
    function setvars()
    {
        $this->name = 'manray';
        $this->age = '28';
    }
    function sayhello()
    {
        echo 'hello ' . $this->name . ' you are ' . $this->age . ' years old';
    }
}
$person = new person();
//there is now a name variable available inside the object
//this brings the scope outside of the class and 'into play' here
$person->setvars();
$person->sayhello();