Posted By

lfatr on 02/16/10


Tagged

improve Better


Versions (?)

MY WRITE BETTER PHP LIST


 / Published in: PHP
 

  1. # Short version if clause
  2. $message = ($age < 16) ? 'Welcome!' : 'You are too old!';
  3.  
  4. # Turn error reporting on / off
  5.  
  6. # Rule Number One: Never, Ever, Trust Your Users
  7. # If you are using SQL, prevent sql injection, always use
  8.  
  9. # Alternatively use addslashes before sending stuff to the database
  10. addslashes($var);
  11.  
  12. # Remove spaces in front and at the end
  13. trim($variable);
  14.  
  15.  
  16.  
  17.  
  18. # good idea?
  19. You should always prefix variables with its type e.g. intNoOfApples or arrArrayOfNumbers

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: alexy on February 17, 2010

Seems a little pointless, because this topic is mentioned on many many websites. First off, sanitizing user input is a plus, and object oriented programming and etc...

You need to login to post a comment.