View Single Post
  #37 (permalink)  
Old 08-17-2007, 08:58 AM
vijayanand vijayanand is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 293
vijayanand is on a distinguished road
Default Re: Website Performance - Tips & Tricks

Problems of style

It's a matter of style and convenience to produce scripts in such a way that make them easy to read and debug. If you are using a programming editor that highlights your code it will be easy to identify the various parts. This may explain why you find syntax that looks rather confusing at first. Some examples:

$line = $result['name'] . ' ' . $result['last_name']; // ok - easy to
read/debug
$line = $result["name"] . ' ' . $result["last_name"]; // ok, but why
use double quotes if they are not necessary?
$line = "$result[name] $result[last_name]"; // ok - but much harder to
read/debug - poor coding style

$line = $result['name'] . ' ' . doSomething($result['last_name']); //
ok - preferred method (using a function)

If you are working with any kind of a team and/or plan on allowing others access to your work in the future it's etiquette to try to make it accessible and easy on the eyes.
__________________

J.Vijayanand
Reply With Quote