Skip to main content
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : Web Architecture : Education - Tutorials
Writing efficient PHP
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
2. Writing efficient code

Reordering statements page 10 of 15

When using a statement, try to place the most frequently-occurring cases at the top of the list. This improves speed and efficiency for the most common cases. For example:

switch ( $user->writingHand )
   case 'right-handed':
      print 'User is right handed'
   case 'left-handed':      
      print 'User is left handed'
      print 'Not sure whether the user is left or right handed!'

Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact