|
Posted by Tom on 10/04/76 11:05
Something I've laboured over for years, in various languages (same issue
in perl, ASP, JSP...).
My personal preference depends on how much of what is being dumped. If
it's a really simple page, then do it in line, I tend to indent it as a
seperate tree to the php code (ie there are two staggers).
However if it's a longer page or includes loads of javascript or
dynamically built tables etc, then I tend to keep the html in another
file wrapped up as php functions with a UI_ prefix. This does make it a
bit slower (calling loads of functions), but the maintenance is loads
easier and it leaves the main code tree legible!
All down to personal preference though. The only hard and fast rule is
to keep it consistent and comment well so that when you pick it up again
a few months down the line you can still maintain it!
eg
<?
include "...../...displayFunctions.php";
nest1
...
nest2
UI_tableRow($arrayOfElements);
more nest2 code
UI_tableEnd;
more nest1 code
....
?>
Tom
>>But what I'm really wanting to get everyones thoughts about is in regard
>>to combining PHP with HTML.
>>
>>I used to do:
>>
>><?php
>> echo "blah";
>> ?><h1>test</h1><?php
>> echo "blah";
>>?>
>>
>>but just tried
>>
>><?php
>> echo 'blah';
>> echo '<h1>test</h1>';
>> echo 'blah';
>>?>
>>
>>
[Back to original message]
|