What's the best way to store class variables in PHP?

前端 未结 5 2519
旧巷少年郎
旧巷少年郎 2021-02-20 11:08

I currently have my PHP class variables set up like this:

class someThing {

    private $cat;
    private $dog;
    private $mouse;
    private $hamster;
    pr         


        
5条回答
  •  长发绾君心
    2021-02-20 12:14

    If you're using private $data; you've just got an impenetrable blob of data there... Explicitly stating them will make your life much easier if you're figuring out how a class works.

    Another consideration is if you use an IDE with autocomplete - that's not going to work with the 2nd method.

提交回复
热议问题