Tame PHP

Posted: (EET/GMT+2)

 

Tame PHP

Sep 28,2000

PHP 3 & 4

By now, you've probably heard of PHP, Professional Home Pages. Shortly put, PHP is a way to build web applications that including advanced functionality such as database access. PHP is a script language similar to Perl and Microsoft ASP, and all the code is (at least almost always) embedded inside an HTML file.

Embedding PHP script into an HTML file has the advantage of keeping the source code simple. The HTML code can created using any HTML editor, such as Macromedia Dreamweaver or Adobe GoLive. When functionality is needed, only then is code written at the appropriate position.

You might wonder what PHP looks like. Well, here's a very simple PHP script:

<HTML>
<H2><?php echo "Hello World!" ?></H2>
</HTML>

As you can see, PHP code is escaped from the regular HTML code using angle brackets and a question mark. When a PHP script file (usually distinguishable with the filename extension .php) is executed using the PHP interpreter, all normal HTML code is sent to the output normally. But when a PHP tag is found, all the commands inside the tags are executed.

Given the preceding example code, the output is:

<HTML>
<H2>Hello World!</H2>
</HTML>


The advantage on the Internet

When you download the PHP binaries from the official PHP site, www.php.net, you get a chance to execute the PHP interpreter as a command-line application. Here's a picture of what it looks like on Windows 2000:

php 4.0.2 running on windows 2000.

Executing PHP on the command line is cool in itself, but the real benefit is when you configure your web server to execute the interpreter. This way, you can take advantage of all the features in PHP in your web applications. For example, if you had a database filled in with your product portfolio, you could easily write a PHP script that would list the items in your inventory.

When thinking of PHP, remember that it is absolutely free. Join the growing number of sites that use PHP (like www.whirlwater.com) to make their user experience richer!

* * *

Want to start using PHP now? Contact us!