Sjoerd Maessen blog

PHP and webdevelopment

Archive for the ‘syntax’ Category

Separating your controller from your view

without comments

What is a controller?
A controller can best be described as the set of instructions and algorithms that are responsible for making your application actually doing something. Often based on user input. You could say your controller is your business logic.

What is a view?
The view is the presentation of your application, the part that our user sees. The view won’t do any processing (like math, checking data,…) it will just show data.

Why don’t you separate your logic and view?
I don’t know how or I don’t use a framework. Those are both often heard excuses when I ask someone why he doesn’t separate the logic and view of his application. Even when you Read the rest of this entry »

  • Share/Bookmark

Written by Sjoerd Maessen

August 9th, 2010 at 12:08 pm

PHP alternative, lazy syntax

without comments

Alternative, lazy what?

Consider the next example:

  1.  
  2. < ?php foreach($aNewsItems as $oItem) {
  3.      echo ‘<li>’;
  4.      echo ‘<a href="/news/’.$oItem->id.‘-’.$oItem->rewrite.‘.html">’.$oItem->title.‘</a>’;
  5.      echo ;
  6. } ?>
  7.  

We could write the above like this: Read the rest of this entry »

  • Share/Bookmark

Written by Sjoerd Maessen

April 12th, 2010 at 7:22 pm

Posted in syntax

Tagged with ,