Re: best way for PHP page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 02 January 2008 09:17:50 Alain Roger wrote:
> Hi,
>
> i would like to improve my coding quality when i use PHP code and for that
> i would request your help.
> in my web developer experience, i have to confess that i've never succeeded
> in spliting PHP code from HTML code.
>
> i mean that all my web pages consist of PHP code mixed with HTML code (for
> rendering pages).
> Some developers tell it's possible to write only PHP code for web page. i
> agree with them but only when those PHP pages do not render web elements
> (write text, display pictures, display formular, ...).
>
> the purpose of my post is to know if i can really (at 100%) split client
> code (display images, write text,...) from server code (move or copy data
> to DB, create connection objects,...)
>
> so what do you think about that ?


Hello,

I believe TYPO3 has good implementation about splitting code and template.

And to archieve clean php code.

1-) Left <html> <?php echo $this; ?></html> model development
2-) Find good template engine. (no not that smarty, it was too big)
3-) use strict dicipline to move html to outside of the code.

Also if you can use the php based template files you can lift off the template 
overhead.

like.

template.php

$strPage = "
<html>
<head.
<title>".$strPageTitle."</title>
</head>
<body>
<table>
<tr>
<td>".$strLeftBlock."</td>
<td>".$strRigthBlock."</td>
</tr>
</table>
</body>
</html>";

process.php

$strPageTitle = getPageTitle($_REQUEST['page']);
$strLeftBlock = getPageBlock($_REQUEST['page'],'left');
$strRightBlock = getPageBlock($_REQUEST['page'],'right');

include('template.php');

echo $strPage;

regards

Sancar

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux