Efficiency of PHP arrays cast as objects?

前端 未结 3 1945
花落未央
花落未央 2021-01-15 20:00

From what I understand, PHP stdClass objects are generally faster than arrays, when the code is deeply-nested enough for it to actually matter. How is that eff

3条回答
  •  感动是毒
    2021-01-15 20:26

    It's more important to chose the right data structure for the right job.

    When you want to decide what to use, ask yourself: What does your data represent?

    Are you representing a set, or a sequence? Then you should probably use an array.

    Are you representing some thing with certain properties or behaviors? Then you should probably use an object.

提交回复
热议问题