9.1 Introduction to PHP


PHP, which stands for PHP: Hypertext Preprocessor (yes, it is a recursive acronym), is an open source scripting language that borrows its syntax from C, Java, and Perl, just to name a few. The result is a language that feels familiar to many programmers. This makes a lot of sense, since the stated goal of PHP is to help web developers create dynamic content quickly, and nothing speeds up coding like knowing the language!

PHP's capabilities are similar to other server-side languages, such as ColdFusion, ASP, and JSP. In addition, because it's an open source language, PHP is constantly gaining new capabilities via extensions. There are even a few extensions that allow PHP to create Flash content dynamically. Furthermore, the PHP Extension and Application Repository (PEAR) offers a huge online repository of PHP components , available at http://pear.php.net or via the special pear command-line tool, which is installed with PHP.

PHP installs onto nearly every server platform available, and it integrates with all of the major web servers, including both Apache and IIS. As its name suggests, PHP is a preprocessor that executes code in PHP pages when they are requested . The result is then sent to the web server and finally delivered to the client. You never have to compile PHP pages explicitly; PHP handles all of the processing of PHP pages for you.

PHP code can be written in either a procedural or object-oriented manner. That said, AMFPHP requires that you write your code as PHP classes. Be aware, though, that if you've used other object-oriented languages in the past, you'll find the OOP capabilities of PHP to be relatively limited. These limitations will be addressed with the upcoming PHP 5.0, so be sure to check out the excellent documentation at http://www.php.net to get the most up-to-date information.

There are two fundamental pieces to PHP's syntax that tend to trip up newcomers. The first is that all variables must begin with a $ symbol. The second is that a period (.), rather than the usual + or & , is used to concatenate strings.

9.1.1 How PHP Fits into Flash Applications

The fact that PHP is available on so many platforms for free means that many hosting providers include it in their service packages. AMFPHP offers a number of installation options; you can even set it up without requiring administrative access to your server. So, while ColdFusion may be the easiest language to use Flash Remoting with from a technical standpoint, PHP is the easiest from an economic standpoint.

The fact that AMFPHP also allows you to connect to SOAP-based web services allows you to use it as a simple connector to pre-existing web services you've written in other languages. Thus, you can add a Flash front end to an existing application without any cost on the server side.

Besides these monetary advantages, using Flash Remoting with PHP provides the same advantages that all of the other Flash Remoting-enabled languages provide. These include the ability to separate architecture and development tasks in a clean manner. Plus, if you design your code well, it's much easier to reuse PHP code you've written for use with Flash Remoting than it is if you were using Flash's LoadVars or XML classes.



Flash Remoting
Flash Remoting: The Definitive Guide
ISBN: 059600401X
EAN: 2147483647
Year: 2003
Pages: 239
Authors: Tom Muck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net