Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn about the Date class built in recently written projects. It is very inconvenient to find that there is no _ get method.
We recommend that you add them officially.
Since there is no _ get magic method, after the class is instantiated, the following functions are useless, which is very inconvenient.
/**
* Date Timestamp
* @ Var integer
* @ Access protected
*/
Protected $ date;
/**
* Time Zone
* @ Var integer
* @ Access protected
*/
Protected $ timezone;
/**
* Year
* @ Var integer
* @ Access protected
*/
Protected $ year;
/**
* Month
* @ Var integer
* @ Access protected
*/
Protected $ month;
/**
* Day
* @ Var integer
* @ Access protected
*/
Protected $ day;
/**
* Hour
* @ Var integer
* @ Access protected
*/
Protected $ hour;
/**
* Points
* @ Var integer
* @ Access protected
*/
Protected $ minute;
/**
* Seconds
* @ Var integer
* @ Access protected
*/
Protected $ second;
/**
* Number of weeks
* @ Var integer
* @ Access protected
*/
Protected $ weekday;
/**
* Complete Expression of the week
* @ Var string
* @ Access protected
*/
Protected $ cWeekday;
/**
* The number of days in a year ranges from 0 to 365.
* @ Var integer
* @ Access protected
*/
Protected $ yDay;
/**
* Complete month Representation
* @ Var string
* @ Access protected
*/
Protected $ cMonth;
/**
* Date CDATE Representation
* @ Var string
* @ Access protected
*/
Protected $ CDATE;
/**
* YMD representation of a date
* @ Var string
* @ Access protected
*/
Protected $ YMD;
/**
* Time Output Representation
* @ Var string
* @ Access protected
*/
Protected $ CTIME;// Add _ get magic Method
// Improved Date
Public function _ get ($ name ){
Return isset ($ this-> $ name )? $ This-> $ name: null;
}For personal ignorance, Do not spray anything inappropriate.
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB