Skip to Main Content
PHP in a Nutshell
book

PHP in a Nutshell

by Paul Hudson
October 2005
Intermediate to advanced content levelIntermediate to advanced
372 pages
11h 35m
English
O'Reilly Media, Inc.
Content preview from PHP in a Nutshell

The Execution Operator

PHP uses backticks (') as its execution operator. Backticks are used very rarely in normal typing, so you might have trouble finding where yours is—it is usually to the left of the 1 key on your keyboard.

Backticks allow you to pass commands directly to the operating system for execution, then capture the results. PHP 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 backticks that you would normally perform directly 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 Chapter 7. Either way, you should be very wary about executing external programs from PHP because of potential security problems.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP Cookbook

PHP Cookbook

Eric A. Mann
Programming PHP

Programming PHP

Rasmus Lerdorf, Kevin Tatroe
Learning PHP

Learning PHP

David Sklar

Publisher Resources

ISBN: 0596100671Errata Page