Does PHP feature short hand syntax for objects?

前端 未结 7 662
囚心锁ツ
囚心锁ツ 2020-12-06 04:04

In javascript you can easily create objects and Arrays like so:

var aObject = { foo:\'bla\', bar:2 };
var anArray = [\'foo\', \'bar\', 2];

7条回答
  •  误落风尘
    2020-12-06 04:23

    There is no object shorthand in PHP, but you can use Javascript's exact syntax, provided you use the json_encode and json_decode functions.

提交回复
热议问题