官术网_书友最值得收藏!

Separation of Concerns

In a proper MVC architecture, we need to separate the view from the models that get our data, and the controllers will be responsible for handling business logic.

In our simple app, we will skip the controller layer since we just want to display the user profiles in one public facing page. The preceding function is also known as the template render part in an MVC architecture.

While there are frameworks available for PHP that use the MVC architecture out of the box, for now we can stick to what we have and make it work.

PHP frameworks can benefit a lot from the null coalesce operator. In some codes that I've worked with, we used to use the ternary operator a lot, but still had to add more checks to ensure a value was not falsy.

Furthermore, the ternary operator can get confusing, and takes some getting used to. The other alternative is to use the isSet function. However, due to the nature of the isSet function, some falsy values will be interpreted by PHP as being a set.

主站蜘蛛池模板: 红原县| 望谟县| 拉孜县| 平塘县| 巴南区| 沙河市| 纳雍县| 慈溪市| 习水县| 桐柏县| 开化县| 平泉县| 罗田县| 桦甸市| 宜州市| 拜泉县| 威远县| 马公市| 桐柏县| 金阳县| 新蔡县| 攀枝花市| 营口市| 汉沽区| 安化县| 曲水县| 固原市| 曲周县| 阜新| 平塘县| 洛扎县| 田林县| 开封市| 博爱县| 砀山县| 九龙县| 开化县| 河津市| 五家渠市| 三穗县| 铜鼓县|