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.
Want to learn PHP 7?
Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!
If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!
Next chapter: Operator precedence and associativity >>
Previous chapter: The scope resolution operator
Jump to:
Home: Table of Contents
Copyright ©2015 Paul Hudson. Follow me: @twostraws.