34,333
edits
Changes
→PHP Execution Operator
Through the use of parentheses around the addition expression we have changed the ''operator precedence'' for that expression.
== PHP Execution Operator - Executing Server Site Commands == All of the operators we have looked at so far are similar to those available in other programming and scripting languages. With the execution operator, however, we begin to experience the power of PHP as server side scritping environment. The execution operator allows you to execute a command on the operating system that hosts your web servber and PHP module and then capture the output. You can do anything in an execution operator that you could do as if you were sitting at a terminal window on the computer (within the confines of the user account under which PHP is running). Given this fact it should not escape your attention that there are potential security risks to this, so this PHP feature should be used with care. The excecution operator consists of enclosing the command to be executed in back quotes (`). The following example runs the UNIX/Linux ''uname'' and ''id'' commands to display information about the operating syustem and user account on which the web server and PHP module are running (note that these command will not work if you are running a Windows based server): <pre><?phpecho `uname -a` . '<br>';echo `id`;?></pre> This results in the following output in the browser window: <tt>Linux xps 2.6.9-42.0.10.ELsmp #1 SMP Tue Feb 27 10:11:19 EST 2007 i686 i686 i386 GNU/Linuxuid=48(apache) gid=48(apache) groups=48(apache) </tt> On a Windows system you could run the ''dir'' command to get a listing of files in the current web server directory: <pre><?phpecho `dir`;?></pre