develooper Front page | perl.advocacy | Postings from August 2001

Re: My list of PHP's shortcomings

Thread Previous | Thread Next
Dan Brian
August 22, 2001 13:33
Re: My list of PHP's shortcomings
Message ID:
The n-tier descriptions can get fuzzy, though. To add to what Andy said, I
have found a good explanation to be that most applications, web or
otherwise, have 3 basic logic types:

  1. Content logic      - the information you give to the user
  2. Presentation logic - the way you display the information 
  3. Application logic  - the way you determine both of the above, 
                        and the functionality the presentation represents

In a typical PHP configuration, either all three are mixed within the
document, or elements of the content are put in a database.

  print "<table>\n";                                     // display logic
  while($line = mysql_fetch_array($result)){             // app logic
      print "\t<tr>\n";                                  // display logic
      while(list($col_name, $col_value) = each($line)){  // content logic
        print "\t\t<td>$col_value</td>\n";          // display & content
      }                                             // app logic
      print "\t</tr>\n";                            // display logic
  }                                                 // app logic
  print "</table>\n";                               // display logic

Granted that Mason and HTML templates encourage a similar markup, there
are other ways to do it in Perl. Part of what makes XSLT and
AxKit solutions attractive to at least a segment of our population (of
which I count myself part of) is the ability to completely separate all
three of the stated logic types. When you have content XML, display
XSLT/XHTML, and separate app logic that generates the content, you have
total separation of that logic.

One reason I think that "lack of n-tier" may not be the best description
of PHP's downfall is because you *can* do n-tier in PHP. Add a query to
the above which will get the display elements from a database, too. Kinda
defeats the purpose of PHP in my mind, but PHP now does XSLT (?) and GTK
(??), so what do I know.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About