You're about to learn to use the most powerful web development language that can be found, and, what's more, you will do so with the minimum of fuss.
I myself started programming in PHP back in 2001 when Perl was at its apogee, and after only two weeks, I had converted most if not all of my scripts into PHP. The reasons I were drawn so strongly towards PHP are many, but mainly it was ease of use – even after having used Perl and ASP so.
Through this blog, I hope for you to be able to switch to PHP in the same kind of time frame, if not less. Back when I made the switch, I was not lucky enough to have a resource like this to learn from!
I am writing this blog with the goal of making the task of learning PHP something fun that you do not have to worry about. As such, you will find lots of information for newcomers, even those who have not programmed much before. On the other end of the scale, I must admit that I have worked hard to put in this blog lots of information on advanced functionality in PHP – if you are a veteran user looking to take your PHP skills above and beyond where they are right now, I am hoping you will find there is lots to be had here.
My goal for this blog is to produce a tutorial you can read in whatever order you want. Once you have the basics down, I encourage you to flick through the table of contents, find something that interests you most, and start reading from there.
This tutorial will be write as a blog, which means you can either use the "Next" and "Back" links at the end of every page to browse your way through the tutorial, or you can just click the links that interest you most.
If you don't fit into one of these categories, you are doing well already:
I cite the last category particular because of Flip Wilson's law: "You cannot expect to hit the jackpot if you do not put a few nickels in the machine".
Before using PHP, Perl was my language of choice for web applications, so I am not short of experience in the language.
The common denominator between PHP and Perl is that they both have roughly the same roots: they are both Unix-like languages, loosely based on C. As such, one of the biggest advantages and the biggest disadvantages in having already learnt Perl is look-alikes. That is, functions or constants that look almost the same, but are different. Or, worse yet, functions that are called the same name but function differently.
For example, the PHP function substr() looks just like the Perl function substr(). Happily enough, it works in precisely the same manner in both languages. On the other hand, a function like rtrim() looks to many like the Perl function chomp() because it trims whitespace from the right-hand side of a string. However, it is actually quite different in that the Perl version only trims new-line characters and returns the number of characters that have been trimmed, whereas the PHP version trims all whitespace by default, and returns the trimmed string.
I strongly recommend that you consult a reference (either this tutorial or the PHP online manual) if you ever have any doubts as to how a function works. Don't just assume that because a function has the same name that it works in the same way!
The syntax and thinking behind PHP is directly based upon C and C++, and it shares many similarities with these languages – particularly when it comes to file handling and operating system functions. Having said that, PHP dispenses with much of the complexity seen in these languages – like Java, PHP only uses references, with no concept of pointers. Similarly, PHP will also perform automatic garbage collection for you, as with Java, although the PHP garbage collection is somewhat less aggressive.
To give you an idea of what you are getting yourself into, please read this short checklist below:
Despite my best efforts to cut out as much fluff as possible, this will be still quite a long tutorial, and programming is largely a dry topic. Having said that, learning PHP need not be a case of reading a chapter a day and memorising things as you go, and there are a number of tips I want to share with you before you start reading that will help you get the most out of this tutorial:
Enjoy the tutorial!
Printed From: http://www.cyberical.com/blog/preface-to-php.html
Back to the original article