If your code includes any special cases where, for example, no action
needs to occur in a function or method, place them as early in the code
as possible and order them from most-likely-to-occur to least-
likely-to-occur.
For example, in the function ConvertToUpperCase shown
below, note that the test for an empty string is coded first. Then
error conditions, such as the end index being less than 0 or
the end index being less than the start index, are coded after that.
function ConvertToUpperCase( $str, $start, $end )
{
if ( $str == "" )
return "";
if ( $end < 0 || $end < $start )
return $str;
if ( $start < 0 )
$start = 0;
$len = strlen( $str );
if ( $end > $len )
$end = $len;
return substr($str,0,$start)
. strtoupper(substr($str,$start,$end+1-$start))
. substr($str,$end+1);
}