Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
PHP 5.4 でサイトを構築し、Windows でロールアップしたところ、PHP 5.3.15 が次のような短いオブジェクト構文を実行すると壊れることに気付きました。$dateGenerated = (new \DateTime())->format("Y-m-d H:i:s");
$dateGenerated = (new \DateTime())->format("Y-m-d H:i:s");
はい、これを変数に設定して問題を解決できます。私は自分のアプリケーション全体でこの種の構文を使用してきましたが、変数に代入する以外にそれを処理するクリーンな方法がまだあるかどうかを知りたいです。
これは、PHP 5.4の新しい構文機能です。
(new Foo)->bar() など、インスタンス化時のクラス メンバー アクセスが追加されました。
そのため、何もする必要はありません。