Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
Using PEAR Console_Getopt To Process The PHP Command Line
Learn to process command-line options in your PHP script

| The Long And Short Of It |

The Console_Getopt class is a PEAR package that provides an API for PHP developers to capture options passed to a PHP program on the command line, and act on them within the business logic of the program. It's currently maintained by Andrei Zmievski and Stig Bakken, – both of whom are PHP core developers - and is freely available from http://pear.php.net/package/Console_Getopt, or as part of the standard PHP distribution. It goes without saying that you will also need to have PEAR itself (PEAR.php) installed in order to use this package.

Command-line options usually come in two sizes: short and long. In the short format, these options are usually preceded by a dash, as in the following example:


shell> php -h


Under the POSIX standard, it's also possible to use longer, human-readable command-line options, preceded with a double dash, as in the following example:


shell> php --help


You can also pass values to a program from the command-line interface, like this:


shell> lynx --term=VT100


The Console_Getopt class works with both short and long options, and also supports option values. The class conforms to PEAR rules on error handling and coding syntax and is, in fact, a fairly important component of PEAR: the PEAR package manager itself uses Console_Getopt for many tasks.


How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system..

Read more, or grab your copy now!


previous page more like this  print this article  next page
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-2010 Melonfire. All rights reserved
Terms and Conditions | Feedback