# PHP and code-behind pages



## jsn (Apr 14, 2004)

Hi all

is there a way to code pages in PHP with the concept of code-behind like in ASP.NET ?

Thanks
jsn


----------



## Captain Code (Apr 14, 2004)

What do you mean by code-behind?  Having the code as a separate file than the php script?


----------



## anarchie (Apr 14, 2004)

You can code in a style that separates content from logic, but PHP has no built-in provisions for making a HTML page programmatically accessible the way ASP does.  For the record, ASP code-behind does use separate files for HTML UI and logic, and ASP uses custom HTML extensions to signify which parts of the page, such as text labels and form fields, are accessible from code.


----------



## jsn (Apr 14, 2004)

anarchie

how do you separate content from logic?

jsn


----------



## anarchie (Apr 15, 2004)

Since you already know about code-behind, try applying it to PHP - make a file full of variables or whatever which contain portions of your page's content.  Then make another file of PHP code which creates a complete web page from those variables.


----------



## Pengu (Apr 15, 2004)

can you maybe show us some examples?


----------



## Gnomo (Apr 16, 2004)

anarchie said:
			
		

> make a file full of variables or whatever which contain portions of your page's content.  Then make another file of PHP code which creates a complete web page from those variables.


I think I understand what you are talking about, but are talking about having a variable for just about every tag or just chunks of html?


----------



## Twist (May 19, 2004)

Almost sounds to me that you are wanting something along the lines of the Smarty template engine http://smarty.php.net/


----------

