类型成员

类

<?php

class Config {
    //类型常量
    const maxConnections = 3;

    //类型字段
    public static $host = "10.0.0.1";
    public static $port = 0;

    //类型方法
    public static function getConnection() {
        return self::$host . ":" . self::$port;
    }
}

Config::$port = 52;
$connection = Config::getConnection();
//connection is "10.0.0.1:52"
echo $connection, "\n";

Config::$host = "10.0.0.3";
$connection = Config::getConnection();
//connection is "10.0.0.3:52"
echo $connection, "\n";