在最简单的形式中,对象是类。
class coOrds {
    // create a store for coordinates
    private $xy;
    function __contruct() {
        // it's still an array in the end
        $this->xy = array();
    }
    function checkXY($x, $y) {
        // check if xy exists
        return isset($this->xy[$x][$y]);
    }
    function saveXY($x, $y) {
        // check if XY exists
        if ($this->checkXY) {
            // it already exists
            return false;
        } else {
            // save it
            if (!isset($this->xy[$x])) {
                // create x if it doesn't already exist
                $this->xy[$x] = array();
            }
            // create y
            $this->xy[$x][$y] = '';
            // return
            return true;
        }
    }
}
$coords = new coOrds();
$coords->saveXY(4, 5); // true
$coords->saveXY(5, 5); // true
$coords->saveXY(4, 5); // false, already exists    
在这里开始阅读它们:http ://www.php.net/manual/en/language.oop5.basic.php