djmzfKnm
djmzfKnm

Reputation: 27195

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?

Upvotes: 4

Views: 2144

Answers (2)

Matthew Vines
Matthew Vines

Reputation: 27581

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.

Upvotes: 2

Matthew Vines
Matthew Vines

Reputation: 27581

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.

Upvotes: 1

Related Questions