Server-Side Solutions with PHP

By Ari Gilder

 

            In a growing Internet age, many more people take to the web to let their voices be heard, to flaunt their fancies or sell their services. With so many people flocking to the World Wide Web, there is an increased demand for more highly interactive content. Simple HTML is not enough to do this alone; in fact, HTML is a small subset of SGML (Standard Generalized Markup Language) from with many other interactive langugaes are written, such as XML, XSL, and VRML. Also, DHTML, Java applets and JavaScript can serve to enhance a page’s dynamicness and interactivity. However, there are some caveats with these languages in the sense that they cannot easily store information. These languages are namely “client-side scripting languages” and, as their name implies, reside solely on the client’s machine. The source code of the page simply informs the client’s web browser what to do and how.

            This client-side method of approaching web programming is not necessarily enough for some people; certainly inadequate for the newer e-commerce web businesses. How are they supposed to store their data? The answer is simple: the site must store their data on it’s own server! This is where “server-side scripting languages” come in. Such languages include ASP, Perl, Cold Fusion, and PHP. As the name implies, all the code is executed on the server first, and whatever the output is is sent to the client’s browser. Thus, if you “view the source” of a PHP or ASP page, you’ll see nothing but HTML and maybe JavaScript, since all the code has been executed already.

            PHP stands for Php: Hypertext Preprocessor (don’t ask me why the first initial is Php – no one knows!) and was made by Zend Technologies. It’s based highly on the C language, like many other scripting languages. Why is it so powerful? Because it allows for simple, quick and easy access to databases, text files and interaction and manipulation of the client’s header variables (the data that a client sends back to the web page when it requests it). Also, there are many useful addons to PHP, such as the GD library, which allows you to create images dynamically. One application of this which I have created (which is available from my website – http://arigi.tripod.com) is a pie chart generator.

            The most powerful feature about PHP has to be its ability to interact with many types of databases, the most common being MySQL (others including PostgreSQL, MS SQL, mSQL, Oracle, etc.). PHP provides simple functions for executing powerful code and storing/retrieving from databases with ease.

            PHP is initialized with a <?php tag and closed with ?>. Like any other C-based language, every statement must have a semicolon after it. The current version of PHP is 4.0.6, and is available for download for free at http://www.php.net. PHP runs most commonly on Apache Web Server software, but can work with most anything.

            If you’d like to get into the web business, I’d definitely recommend you learn PHP. A good starting point would be to read the book Professional PHP Programming from Wrox Press Publishing. It’s a pretty fat book, and you don’t need to read it all (in fact, I recommend you not read it all), but it will definitely serve as adequate material to learn PHP from.