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

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.

主站蜘蛛池模板: 阜阳市| 玉龙| 临桂县| 恩平市| 武清区| 万宁市| 德钦县| 五峰| 叙永县| 巴马| 英超| 葫芦岛市| 萨迦县| 大厂| 无极县| 岳西县| 合作市| 孟村| 华池县| 南华县| 镇远县| 武宣县| 通山县| 江都市| 塔河县| 旅游| 屏东市| 黄大仙区| 航空| 崇州市| 南陵县| 会同县| 罗山县| 甘南县| 张家川| 武隆县| 新沂市| 呼图壁县| 屯昌县| 杭州市| 盐津县|