1/16/2010

Welcome... and first few tips!

Welcome to my new blog featuring some of my PHP tutorials. Here I'll try to share simple and elegant hacks that will help you not only solve varios problems but solve them in easier, quicker and more elegant way.

Being a great PHP developer doesn't mean to know each and every function and feature of the language. It means to solve the real world problems in efficient way. This is what the blog is going to help you for.

Let's start with a few random smart tips




  • Using the alternate PHP syntax in the HTML code will make it much cleaner and easier to follow.

  • Make your own database object or download a class online instead of using the PHP built-in functions like mysql_query etc. It's not that you are going to change the DB engines (it's unlikely) - it's about using far more comfortable functions that return directly arrays of objects of the results you are selecting.

  • Don't forget about the HEREDOC syntax.

  • When passing IDs in the URL check them with is_numeric() function. In many cases this is all you need to avoid attacks.

  • Use good PHP editor such as CodeLobster.

  • Put a small comment at the beginning of all your PHP files. This is extremely useful when you return to old code.

  • Use variable names that make sense. For example when selecting users from the DB call the result array $users instead of $rows. This will help you when the variable appears 10 lines later.



These tips are very basic, but I promise that's just the start. There are a lot more useful things coming in place here. Stay tuned!

1 comment:

  1. Offshore Outsourcing Software Development Company Etisbew - We have got useful information from your blog, please keep posting such information in future.

    ReplyDelete