One of the best things about PHP is that it’s easy to learn. Whether you’re a seasoned programmer or you're trying to build on your Web design skills, PHP’s intuitive structure and familiar syntax makes picking it up a snap. This roundup of articles will help you hit the ground running and add another skill set to your arsenal.
What is PHP?
PHP (which stands for PHP Hypertext Preprocessor) is an open-source server-side scripting language intended specifically for use on the Web. Like ColdFusion and ASP, it has both inline and stand-alone scripting capabilities. And like C++ and Java, it has a heavily object-oriented structure. But unlike its competitors, it’s free.
PHP has increasingly become a viable solution for enterprise development. It has found its way into many companies and, once there, it sticks. The fact that it operates on several platforms is a bonus, along with its appeal to developers from a variety of backgrounds.
For more information on PHP’s background, and for some fodder you can use to justify using PHP, check out the article "PHP: An alternative for server-side scripting." It also offers a basic example of how PHP works and some links to useful PHP resources, including where to get PHP and how to install it.
Where do I start?
Once you’ve worked through the overview, getting started is easy. PHP has a huge community following and lends itself to open-source programming, so finding free examples online is a cinch. Whether you like to learn by taking preexisting code and modifying it or starting from the ground up, plenty of tutorials, help groups, and free scripts are available.
The article "Tutorial: Getting started with PHP" introduces the basic language syntax and constructs, with a short example. It also includes links to other tutorials on the Web and free script resources to get you up and running.
How do I do something interesting?
Basic syntax was easy, so now you should be ready to move on to the big time. You've seen that PHP is an inline language ideal for Web use. Now check out the article "Understanding functions and classes in PHP" for a detailed look at a Web form application. After working through the example provided there, you should have a feel for PHP’s powerful object-oriented features. Additionally, you’ll learn how to display to and receive variables from the Web, write to and read from a file, and send e-mail with PHP.
If you have any experience with C or C++, you'll notice that the code structure in the Web form example looks familiar. As a result, you'll be facing a shallow learning curve. And if PHP is your first language, you’ve exposed yourself to structures similar to those in other popular languages.
How do I do something useful?
Brain not full yet? That’s okay. We've got more. To unleash the awesome power that is the Internet, you really need a database. PHP offers connectivity to all major contenders in this area, as well as quite a few minor ones. Because PHP is open source and appeals to that community, MySQL is probably the most popular one used in conjunction with PHP.
The article "Use PHP for database access and deliver dynamic Web content" discusses the various options available for connecting to databases. To help you on your way, it walks through a MySQL example and discusses the functions you can use to manipulate requested data. After reading the article, you should be able to achieve pretty much anything you could ever want to do with a Web site.
Do I have to do everything myself?
While it may be lots of fun to write code in PHP, you don’t have to keep reinventing the wheel. PHP's popularity with the open source community has also led to the development of many resources that are helpful to both advanced and beginning users. One such resource, PHP Extension and Application Repository (PEAR), is a venture similar to Perl’s CPAN. It consists of a code library written with strict guidelines for optimum distribution.
In the PEAR library, you'll find lots of free, useful functions, including error checking, database connection, logging, sending e-mail, and much more. PEAR has a decent following and is actively maintained. The article "Speed PHP application development by using PEAR" explains how to take advantage of PEAR modules so that you can spend your programming time creating the more interesting pieces of your application.
So there you have it—the ultimate guide for jumping into PHP and landing on your feet. If these articles aren’t enough to get you going, some of the links included in them may help. And if you have specific questions, you can post a comment below. You'll find plenty of other PHP content on this site as well, including a more detailed look at sending e-mail, using session objects, and other fun stuff.
Want to see more about PHP? Post a request for topics or send us an e-mail. Now that you’ve seen how easy it is to write the code, join the PHP community and show off your new skills by bragging in the discussion area below.