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

| Your Wish Is My Command Line |

The traditional view of PHP is that of a server-side scripting language, embedded in HTML documents and invoked by a Web server. In fact, if you're new to PHP, you might be forgiven for thinking this is the only view - after all, it's quite likely that you haven't yet seen PHP being used in any other context.

Well, surprise, surprise - the PHP distribution includes a command-line interface, which allows you to create and run PHP scripts at the command line without needing either a Web server or an HTML wrapper. This command-line interface, or CLI, is mostly used for shell scripting, and comes in very handy for automating routine console-based tasks... especially if you're already familiar with PHP and don't really want to learn another language such as Perl or bash.

Now, you probably already know how to send options to a PHP program to modify its behaviour. With a web-based PHP application, these options may be passed through a form, through session variables, or in the URL string. With a console-based PHP script that runs through the CLI, the options must be passed on the command-line itself. Of course, this means that you need a way to parse these options, decide what each one means, and modify the behaviour of the script appropriately.

That's where this tutorial comes in - it shows you how to painlessly support command-line options in your PHP CLI programs. It's not as difficult as it might seem at first glance - and no, you don't need to stay up all night to get it done. All you really need is a copy of Console_Getopt.

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!

more like this print this article  next page
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
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
In cut!...
American Chai
The Core
Find out how you can use this article on your own Web site!

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