On Tue, Sep 17, 2002 at 09:01:52AM -0700, Bob Miller wrote:
> Jacob Meuser wrote:
> 
> > Granted, php will let a person write horrible code.  One way
> > to minimize the ugliness is to use php.ini-recommended instead of
> > php.ini-dist as the php.ini.
> 
> My problem with PHP is that it doesn't give you any tools to separate
> presentation from logic.  A typical PHP page has a bunch of HTML
> marked up with a bunch of PHP.  You have to read around the PHP to see
> the formatting, and read around the formatting to see the PHP.
> Changing either one means editing both, and they interact in strange
> ways.

Well, the question is, do you want pretty pre-processor code, or
pretty final code?  Personally, I prefer pretty final code, because
that's what matters most when it's debug time (does it matter if you
write pretty C, but the resulting executable doesn't work right and
gives unreadable error messages?).  Even in my mod_perl "pages", I use
'print' instead of the CGI calls like 'start_html' because I know
exactly how the HTML is going to be formatted.  Yes, this takes extra
care, but if you put your newlines first instead of last, and use
capitals for HTML tags, it's not so bad, eg:


<HTML>
  <HEAD>
    <TITLE>A php demo</TITLE>
    <META name="description" content="A demontration of pretty php/HTML">
  </HEAD>
  <BODY>
    <H2>A pretty php demo</H2>

<?php

    # I use a 2 space indent for HTML, 4 for php, since my HTML
    # is usually twice as nested.  I don't suggest running this
    # example, BTW.

    for ($i = 0; $i < 10; $i++) {
        $j = pow($i, 2 * $i);
        for ($x = $i; $x < $j; $x++) {
            echo "
    <P>
      i = $i
      x = $x
    </P>
    <P>
      Yes, this looks out of place at first, but you learn to find
      your 'echo' statements rather quickly.
    </P>";
        }
    }

?>

  </BODY>
</HTML>


Of course, I learned php and HTML more or less at the same time,
so I didn't have any concrete notions about one separate from the
other.

-- 
<[EMAIL PROTECTED]>
_______________________________________________
Eug-lug mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug

Reply via email to