Hudzilla.org - the homepage of Paul Hudson PHP and PHP
Contents > Simple variables and operators > Operators Wish List | Report Bug | About Me ]

3.12.6     The execution operator

NOTE: This is NOT the latest copy of this book; click here for the latest version.

The least complicated of all three special operators is the execution operator, which is ` - a back tick. Back ticks are used very rarely in normal typing, so you might have trouble finding where yours is - it is almost certainly to the left of your 1 key on your keyboard. It may well share a key with other obscure symbols such as ¬.

The execution operator in PHP is very clever - it allows you to pass commands direct to the operating system for execution, then capture the results. PHP literally replaces the result of the execution with what you asked to be executed. For example:

print `ls`;

That will run the command "ls" and output its results to the screen. If you are using Windows, you will need to use "dir" instead, as ls is only available on Unix. You can perform any commands inside back ticks that you would normally perform direct from the command line, including piping output to and from and/or redirecting output through other programs.

There are several functions that perform program execution like the execution operator - you can find a more comprehensive reference to them in the Functions chapter.



<< 3.12.5 The scope resolution operator   3.12.7 Operator precedence and associativity >>
Table of Contents
Top-right shadow
 
Bottom-left shadow Bottom shadow