Re: [PHP] Re: Frequent Mode Switching

2003-08-10 Thread Jason Sheets


Kevin Stone wrote:

I used to program that way.  The logic and presentation portions of my
scripts were combined into one or two monolithic files.  That worked well
for small projects.  But as I got involved in larger projects and had to
juggle many code files at once I found that I prefered to separate as much
of the HTML from the PHP code as possible.
 

Typically what I do now is set up my HTML in a template-like format using
?= $var? as the outputs.  

?= is discouraged and is known to break some files, the full use if 
?php is encouraged, they have been several threads discussing the use 
of ?= and where there is not a ?php=, search the archives for more 
information.

Jason

$next_year
$prev_year
$cur_year
$cur_month
$cur_day
$january
$february
$march
$april
$may
$june
$july
$august
$september
$october
$november
$december
$event_list
$event_header
Each output contains a portion of the final calendar page.  So I could take
the months and put them into rows or columns, take the event list and put it
on the top or the bottom, take the interface elements and place them where
they work best.  Or I can ignore half of the outputs and display only one
month if I wanted to.  Point being I could do this in a fraction of the time
it would take me to do it in logic portion of the script.
Anyway.. just my two bits.  Take it or leave it.  :-)

- Kevin



 



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


[PHP] Re: Frequent Mode Switching

2003-08-10 Thread Kevin Stone

Derrick Fogle [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Thoughts on frequent switching in and out of PHP mode:

 ? switch in, do some code
 ?Switch out, static HTML
 ? switch in, do more code
 ?Switch out, more static HTML

 I've found that I prefer programming this way, for the most part,
 putting most of the heavy PHP programming at the top, and then using
 static HTML interspersed mostly with quick ?= $variable ? statements
 for what users see.

 I'm sure there's more than one viewpoint out there, so I'd like to hear
 a couple of them. Is this frequent mode switching good, bad, or
 indifferent? Is there a point at which the mode switching starts to
 seriously degrade performance and reliability?

 -Derrick


I used to program that way.  The logic and presentation portions of my
scripts were combined into one or two monolithic files.  That worked well
for small projects.  But as I got involved in larger projects and had to
juggle many code files at once I found that I prefered to separate as much
of the HTML from the PHP code as possible.

Typically what I do now is set up my HTML in a template-like format using
?= $var? as the outputs.  Very little logic goes between the ?php? tags
in my HTML files but of course sometimes it's unaviodable and that's why you
want to use ?php? tags here and not some phoney template language.  Then
sipmly include() the HTML file back into the script allowing the outputs to
fill in.  This makes for a very 'plastic' interface that you can mold very
easily in an HTML editor without screwing up your script.  For example I did
a calendar script recently with the following outputs...

$next_year
$prev_year
$cur_year
$cur_month
$cur_day
$january
$february
$march
$april
$may
$june
$july
$august
$september
$october
$november
$december
$event_list
$event_header

Each output contains a portion of the final calendar page.  So I could take
the months and put them into rows or columns, take the event list and put it
on the top or the bottom, take the interface elements and place them where
they work best.  Or I can ignore half of the outputs and display only one
month if I wanted to.  Point being I could do this in a fraction of the time
it would take me to do it in logic portion of the script.

Anyway.. just my two bits.  Take it or leave it.  :-)

- Kevin



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