PHP Variable vs Array vs Object

前端 未结 7 1359
忘掉有多难
忘掉有多难 2020-12-31 18:03

This is probably considered a really silly question, but I\'m in the process of putting together a simple template system for a website and am trying to keep track of my var

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 18:43

    I would consider it unnecessary overhead. Doing what you are talking about in an object oriented way only means that inside your class you will have done nothing more than create a bunch of variables... just as you specified in your first example.

    The array is the best way to go in my opinion. You are only using one variable... and you can also integrate it into your Class. So instead of $tpl->title, you may have $tpl->text['title']

提交回复
热议问题