Introduction
I have no intention of writing a PHP tutorial. Many already exist around the web including, obviously at php.net.
However, as I develop Drupal sites, I often share some PHP scripts with webmasters. One has expressed the desire to learn PHP. This article is then a small guide on how to make the most of what's already available on the web, and also using my PHP code snippets as a basis for the curriculum.
Identifying various elements within a script
A PHP script that I write for a Drupal site would typically contain several of the following elements:
The links point to the most relevant documentation for each element.
If you are trying to adapt a given script to your needs, you must first understand how it works. To do so, you must know to which element the bits you don't understand correspond, and check in the relevant documentation.
Security
There comes a time during a person's learning process when it can be said that that person knows enough (PHP) to be dangerous. What this means is that the person might believe him or herself proficient enough to create their own PHP script and use them within live environments. The appearances might lead the learner to believe that the script works perfectly. However, there might be some security holes in the script and some of those, if discovered by the wrong kind of people, can have disastrous consequences for the site.
So, if you are learning PHP, for as long as you can get your scripts vetted by someone with more experience, especially in the field of writing secure PHP code. You can learn valuable lessons from their feedback without the need for those lessons to be learned through avoidable disasters.