print_r() adds properties to DateTime objects [duplicate]
问题 This question already has answers here : Why can't I access DateTime->date in PHP's DateTime class? Is it a bug? (5 answers) Closed 2 years ago . Consider the following code sample: $m_oDate = new DateTime('2013-06-12 15:54:25'); print_r($m_oDate); echo $m_oDate->date; Since PHP 5.3, this produces (something like) the following output: DateTime Object ( [date] => 2013-06-12 15:54:25 [timezone_type] => 3 [timezone] => Europe/Amsterdam ) 2013-06-12 15:54:25 However the following code: $m_oDate