What are the benefits of using the __get() method and __set() method instead of setting public properties directly?
小毛
小毛 2018-04-21 11:31:56
0
0
1249

Although compared to the PUBLIC attribute, the magic method can control read-only and write-only, but the two magic methods are useful for all private members. If you want to control only some of them, you need to write an If judgment. If this is the case, it is better to set the attribute to PUBLIC directly. So, my question is are there any other benefits to the two magic methods?

小毛
小毛

reply all (0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!