Next Previous Contents

17. General purpose programming with PHP

PHP is very powerful and is designed such that it can replace awk, sed, UNIX shell, perl, "C", C++ and Java.

The object oriented features of PHP is developing very rapidly and in near future will surpass the object oriented features of Java language. All the object oriented features are implemented in PHP via class keyword just like in Java.

If you build the CGI version of PHP, you can use it from the command line simply typing: php filename where filename is the file you want to parse. You can also create standalone PHP scripts by making the first line of your script look something like:


    #!/usr/local/bin/php -q
The "-q" suppresses the printing of the HTTP headers. You can leave off this option if you like.

If you want to use PHP as a stand-alone program, just like a shell script, "C" or perl program, then use this technique:


bash$ php -q filename.php
bash$ php -h
bash$ php -?
bash$ /usr/bin/php -?
bash$ php -i

The command php filename.php will execute the file filename.php. You are invoking the php program which you wrote in filename.php from the bash commmandline instead of from the web-browser.

On Microsoft Windows platform you will bringup a MSDOS prompt from Start->Run->cmd and put C:\Program Files\php\bin in your path environment and


C:\> php -q filename.php
C:\> php -h
C:\> php -?
or
C:\> c:\Program Files\php\bin\php filename.php

17.1 Standalone MS Windows GUI applications using PHP

Since PHP is general purpose scripting language and is like a "glue" language, you can use it develop standalone MS Windows GUI applications. PHP can be very easily combined with MS Windows C++ GUI classes to create GUI applications. And developing applications with PHP is extremely fast as it is a scripting language and it's runtime performance is also excellent as compared with other scripting languages like Perl, Visual Basic and Python.

PHP can also be used for developing standalone GUI applications for Linux/UNIX'es.


Next Previous Contents