(Almost) Everthing an experienced programmer needs to know to get started with PHP
24 Jan 2011I consider myself to be an experienced programmer. Having spent the last 10 years working on a variety of platforms like Windows and Linux, using different programming languages like Java, C#, VB, Ruby, JavaScript etc, I feel that I have a broad experience and understanding of programming. However, there is always that moment when one must use a different language, for whatever reason. In my case I had to start tinkering with a site developed by someone else in PHP. Now I have always tried to avoid PHP since I was very much into compiled languages like Java and C#. Since breaking away from the corporate world, I have been able to move to scripting languages like Ruby, JavaScript and now PHP.
What I want to do is briefly summarize what an experienced programmer needs to know to get started with PHP. I managed to build a simple site in PHP in less than one week using PHP / MySQL / Apache on Linux (commonly known as LAMP stack). I will just list some of the things that I found useful during the journey. The site I built by the way is for my very own Computer School in Cambodia (shameless personal project plug, I suppose, but only if your in Cambodia .
Note: To place PHP script inside a page you need to open with and close with ?>
Setting variables:
String concatenation is done with dots!
Connecting to a database
Execute a query and count results
Get a value from the resultset
IF statements
Output values in HTML rendering
Date formatting
More details of date formatting in PHP
Server Side Includes