简体   繁体   中英

Alternative of ASP.NET's UserControls in PHP?

I have developed many web applications in ASP.NET in which I have make use of UserControls to manage header footer and any other common part of a web page. Now I am developing an app in PHP, is there anything which I can use as an alternative of UserControls??

How I can implement the similar concept in PHP?

Thanks?

A second answer which is a bit harder to explain in detail here, is to build your own 'UserControl' classes. The Classes would have the neccessary properties that you require, and Would have a RenderHTML() method that would output the control to the screen.

The UserControl concept does not explicitly exist in PHP, though you can encapsulate the the functionality that you want in a file and use the include() function to place it into your pages where you wish.

<html>
 <head>
   <title></title>
 </head>
 <body>
   <?php include('header.php'); ?>
   <?php include('pageBody.php'); ?>
   <?php include('footer.php'); ?>
 </body>
</html>

Note that Smarty provides for much better separation of processing and rendering, and will make this type of thing super smooth.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM