Class Member Access on Instantiation
问题 In PHP 5.4, I believe something like this is valid: echo ( new DateTime( '2014-04-05 10:36am' ))->format( 'Y-m-d g:ia' ); On PHP 5.3, I currently do something like this: $date = new DateTime( '2014-04-05 10:36am' ); echo $date->format( 'Y-m-d g:ia' ); Any way to combine those two lines into a single line in PHP 5.3 (and I don't mean by concatenating the lines)? Or will I have to upgrade to >=5.4 to have that option? 回答1: Will I have to upgrade to >=5.4 to have that option? Yes. You need to