Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 1
    Personally, I would go for option 3: objects. PHP is an object-oriented language, not an arrays-of-arrays-of-strings-oriented language. (Well, sort of. It's not a particularly good object-oriented language, but it is one.) Commented May 23, 2016 at 19:14
  • So you create a stdClass object and then fill it like option 2? I feel that in PHP there arent much differences between an assoc array and an stdClass object. Commented May 23, 2016 at 22:13
  • 3
    No, you should have Css objects, Meta objects, HeaderJs objects, BodyJs objects, PhpInclude objects, etc. and those should implement a common interface (say, PageElement) with a render method and should know how to render themselves. Then you simply call render and don't care what kind of object it is, because it takes care of the rendering itself and there is no switch needed at all. Commented May 23, 2016 at 22:27
  • @JörgWMittag That sounds like an answer to me. Commented May 25, 2016 at 10:51
  • Indeed, if you post it like an answer, maybe with a little example(?), I will accept it :D Commented May 25, 2016 at 10:59