Intermediate and Advanced PHP coding Tips from PHP Experts

  • Use CMS or Frameworks
  • Never ever Trust user inputs
  • Use isset() instead of simple checking variable inside if condition
  • Use static variable cache
  • Always initialize your PHP variables
  • Know the Difference Between Comparison Operators
  • Suppression Operator Carefully
  • Look for existing Apis befor writing your own!
  • Do not misuse session
  • Prefer single quotes for wrapping string
  • Wrap array Indexes with single quotes
  • Use full PHP tags
  • Evaluate loop limit value outside loop whenever possible
  • Document your code properly
  • Use dynamic variables carefully
  • Favor str_replace() over ereg_replace() and preg_replace()
  • Use Ternary Operators
  • Use the Suppression Operator Correctly