| 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!