Beginner in php: how to implement the c # master page in php-php Tutorial

Source: Internet
Author: User
Tags smarty template
New to php, I have always been using c # to implement the c # master page in php. net website. I encountered a problem when I first started learning php. could you help me to see how to solve it?

In the previous. net small web page system, the master page has a region dedicated to displaying the user name and ip address after login.

But because php does not have a master page, I want to write a general layout of a page (hereinafter referred to as master. php), include in other pages is equivalent to implementing the "master page" function, but encountered the following problems:


Since the master. php only writes the layout, how should the content to be displayed on different pages be put into the master page?

For example, in c #, the master page has asp: ContentPlaceHolder.

And I am in the master. write the layout in php. all the controls written on the new page are in the master. outside the php area (the display is messy, because the control is not placed in the correct position at all). how can I solve this problem?

Or is there any more common and better way to achieve this effect? Thank you!


Reply to discussion (solution)

Either use the inheritance in the framework, or implement the inheritance function by yourself, or you can separate the layout and include it with include.

Consider using the smarty template.

Use include, or refer to TP to have a template inheritance (no template inheritance is used)

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.