In this section of this PHP tutorial I will be listing good practices in PHP developement that will help you when you need to re-code, troubleshoot or if someone else has to get familiar with your code at some point or If you like to produce an elegant code in general:

  • Always comment your code~Let everyone know what does this part of the code do, you don’t need to over do this just simply add a line at the begining of each block of code or every few blocks.
  • Also add beggining and end comment that will make it easier for you to find a specific code segment.
  • Try not to use the shorthand codes if your code is going to be moved at one point in the future to a server that you have no control over.
  • Don’t cramp all codes in one place, use spaces as much as you need, PHP does not process that so you can use as much of it as you need.
  • Organise your code by indenting the blocks inside blocks this way you don’t loose track of the “quotations” and “curly brackets”.
  • Always, Always, Always check and rechack the data that you have recieved from any source. As long as you have recieved data from an external source always filter them.