您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

建议官方在Date类加上魔术方法__get

2024/6/28 13:27:43发布23次查看
最近写项目用到了内置的date类,发现在没有__get方法,非常不方便。
建议官方给加上。
由于没有__get 魔术方法,实例化类之后,下面这些形同虚设,非常不方便。    /**
     * 日期的时间戳
     * @var integer
     * @access protected
     */
     protected $date;
/**
     * 时区
     * @var integer
     * @access protected
     */
     protected $timezone;
/**
     * 年
     * @var integer
     * @access protected
     */
     protected $year;
/**
     * 月
     * @var integer
     * @access protected
     */
     protected $month;
/**
     * 日
     * @var integer
     * @access protected
     */
     protected $day;
/**
     * 时
     * @var integer
     * @access protected
     */
     protected $hour;
/**
     * 分
     * @var integer
     * @access protected
     */
     protected $minute;
/**
     * 秒
     * @var integer
     * @access protected
     */
     protected $second;
/**
     * 星期的数字表示
     * @var integer
     * @access protected
     */
     protected $weekday;
/**
     * 星期的完整表示
     * @var string
     * @access protected
     */
     protected $cweekday;
/**
     * 一年中的天数 0-365
     * @var integer
     * @access protected
     */
     protected $yday;
/**
     * 月份的完整表示
     * @var string
     * @access protected
     */
     protected $cmonth;
/**
     * 日期cdate表示
     * @var string
     * @access protected
     */
     protected $cdate;
/**
     * 日期的ymd表示
     * @var string
     * @access protected
     */
     protected $ymd;
/**
     * 时间的输出表示
     * @var string
     * @access protected
     */
     protected $ctime;// 添加__get魔术方法
// 改良date
    public function __get($name){
        return isset($this->$name)?$this->$name:null;
    }个人愚见,如有不适当之处,勿喷。
ad:真正免费,域名+虚机+企业邮箱=0元
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product