Community member “a_v58” sent me a short list of PHP tips. These days, people are rabid in their thirst to learn more about PHP. If you want to become a programmer, you should know what you’re doing when it comes to PHP. The following tips were sent in to me by Andrew. They are solid tips, so I wanted to pass them along to all of you.
- Don’t be tempted to use packets such as WAMP or XAMPP that install and configure Apache, PHP, MySQL for you automatically. You’ll learn more by installing them one-by-one and configuring them manually. After a quick Google search, you’ll find a list of recommended configurations for PHP and/or Apache – depending whether your machine is a server or a development machine. I recommend installing in this order: MySQL, Apache, PHP.
- A small suggestion to check if all 3 were installed and configured correctly: place a small PHP script in the .htdocs directory of Apache in which you call the phpinfo function, as well as one function from every extension (MySQL, cURL, Java, etc.). If there are no warnings or errors, everything should be fine.
- For fewer headaches and happier programming, I also strongly recommend using an IDE such as EclipsePHP (which can be found at eclipse.org) or Zend. You might also look into xDebug.
- Remember to sanitize your database inputs. To avoid this, understand what this is and how this works. Google or read on Wikipedia for “SQL injection.” Use functions such as ‘addslashes’ and ‘get_magic_quotes_gpc.’
- When you think you did everything right and you don’t understand why something isn’t working, look at your code carefully, debug it, and possibly run a ‘var_dump’ on all the variables to see whether something is faulty. If you still can’t figure it out, take a break and get some fresh air. Come back to the problem with a clear mind.
- Don’t be afraid to ask on forums or the community questions. Remember: there are no stupid questions. However, if for every little mistake you ask, and you don’t figure a couple of questions on your own… no offense: programming may not be right for you.
- Why choose PHP? It has a syntax similar to C/C++ (which are some of the used frequently for desktop applications. PHP.net has almost everything you might need to know – including examples and user-contributed notes (which may contain exactly what you need).
- When somebody asks you a question, don’t be afraid to answer. You’ll either help that person by teaching him or her something new (or be corrected by someone with more experience – in which case, you’ll learn something new).
Sure, it’s a starter list of tips – extremely rudimentary for some. That’s where you have the opportunity to suggest your own PHP starter tips in the comments stream below. 🙂