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

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.

主站蜘蛛池模板: 武鸣县| 东光县| 抚松县| 永善县| 留坝县| 永胜县| 长寿区| 晋江市| 集贤县| 印江| 江安县| 嘉兴市| 白水县| 宝清县| 会东县| 视频| 南召县| 忻州市| 墨脱县| 寿光市| 昌都县| 萝北县| 郸城县| 石屏县| 锡林浩特市| 庆阳市| 承德市| 平安县| 梁河县| 稻城县| 临潭县| 阿图什市| 湘潭县| 岳阳县| 施甸县| 威信县| 小金县| 枝江市| 桐城市| 竹溪县| 克山县|