PHP Framework 3 (view)

Source: Internet
Author: User
Tags php framework
PHP Framework Three (view)

In the previous section we simply implemented the controller. In this section we implement a view.

This view is very simple. The main use is Ob_start (), ob_get_content (); This file is located in the includes folder

view.php

 

For the OB function, we can simply assume that after PHP is compiled, it does not return to the page immediately, but rather first to the buffer.

The above view just makes a simple implementation, if we want to extend it, we can improve the Set_view_type () method, can also increase the cache, also can increase the support of the template.

Concrete implementation I will add in a later chapter, today we try to use this view.

or the index.php file under the Controller folder yesterday

 
   ' HELLO World ');}}

Then create a new default folder within the View folder, and then create a new index.htm

 
   

We run the site and we can see the results, "HELLO world".

I think the result is a testimony to the new ideas of every programmer.

If in this file you also want to insert the head, or the tail, just create a new head.htm. And then join in the index.htm.

 
   

It is possible to join the public sector.

At this point, our small view class is implemented.

We can go to the experiment on our own, if not, we communicate again.

The next section is the DAO layer that I used to introduce in my blog, namely modules.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.