Edit report at https://bugs.php.net/bug.php?id=53097&edit=1

 ID:                 53097
 Updated by:         fel...@php.net
 Reported by:        cmanley at xs4all dot nl
 Summary:            Allow creating object without variable assignment
                     and calling method inline
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 PHP Version:        5.3.3
-Assigned To:        
+Assigned To:        felipe
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2011-11-11 10:51:04] cmanley at xs4all dot nl

Nice. It seems to be added in PHP 5.4 RC1 even though nobody seems to have 
handled 
this feature request I wasted my time on.

------------------------------------------------------------------------
[2010-10-19 13:50:04] cmanley at office dot caiw dot nl

@derick
Thanks, but that was simply an example. It could've been any (even user 
defined) class.

------------------------------------------------------------------------
[2010-10-18 15:59:52] der...@php.net

As a workaround, you can do:

print date_create('now')->format('Y-m-d H:i:s'), "\n";

------------------------------------------------------------------------
[2010-10-18 14:59:35] cmanley at xs4all dot nl

Description:
------------
In other languages I can do things like this, but PHP5 barfs when I try to do 
it:
print (new DateTime('now'))->format('Y-m-d H:i:s')

Instead I have to use a temporary variable:
$x = new DateTime('now');
print $x->format('Y-m-d H:i:s');
unset($x);


Test script:
---------------
php -r "print (new DateTime('now'))->format('Y-m-d H:i:s')" 

Expected result:
----------------
The date+time stamp.


Actual result:
--------------
PHP Parse error:  syntax error, unexpected T_OBJECT_OPERATOR in Command line 
code on line 1


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=53097&edit=1

Reply via email to