Bash scripts can simplify many OS-oriented tasks for PHP developers. Even better, you can run Bash scripts directly from PHP, passing arguments, arrays, and receiving output that you can analyze or display.
Following Darrell Brogdon's previous article on using PHP as a shell scripting language, this article covers some advanced uses of the language and shows some tricks that make PHP an extremely useful language to work with.
Unlike Darrel's article however, this one will also cover the Windows version of PHP as well as the Linux/Unix one. First, however, there are a couple of differences you need to be aware of.
As most of us already know, PHP is the best language for developing dynamic web pages available today. Not many people are aware that it can be used as a shell scripting language as well. While PHP as a shell script isn't as robust as Bash or Perl it does have definite advantages, especially if you're like me and are more proficient in PHP than you are in Perl.
The requirements for using PHP as a shell language is that you must compile PHP as a CGI binary instead of as an Apache module. There are certain security issues related to this so please refer to the PHP Manual when doing so.
As most of us already know, PHP is the best language for developing dynamic web pages available today. Not many people are aware that it can be used as a shell scripting language as well. While PHP as a shell script isn't as robust as Bash or Perl it does have definite advantages, especially if you're like me and are more proficient in PHP than you are in Perl.
PHP is most often used in combination with a Web server, to dynamically generate Web site pages. However, this Web server interface isn't the only way to use PHP, because the PHP distribution also includes a command-line interface which can be used to run PHP programs at the command prompt, much like Perl or bash.
This document will introduce you to PHP's command-line interface (CLI), showing you how to interact with PHP programs at the command prompt.
PHP is most often used in combination with a Web server, to dynamically generate Web site pages. However, this Web server interface isn't the only way to use PHP, because the PHP distribution also includes a command-line interface which can be used to run PHP programs at the command prompt, much like Perl or bash.
Nicht nur zur Programmierung dynamischer Websites ist PHP geeignet. Auch auf der Shell, z.B. zur Systemverwaltung lässt sich PHP einsetzen.
In this article, Jason will explain what CLI and Cron are and how to use them together within the PHP environment.
Who says you have to use Perl to shell script? Jayesh definetly doesn't, and in this article he will show you how to shell script with PHP instead!
Last week I continued my discussion of the console BlackJack game developed to illustrate how to use PHP to write console scripts. This week I'll be concluding my discussion of the BlackJack script by explaining the last two functions in the BlackJack script. The first function in today's discussion will be the new_hand() function which deals with the steps required when dealing a new hand of BlackJack. The second function is labeled main() and serves as the "brain" of the PHP script controlling all user-interaction and the majority of the logic code involved during a hand of BlackJack.








