Backtick Operator

July 11th, 2008

I just learned something new today in PHP.  It’s the Backtick Operator.  What it does is executes a shell command and captures its output.  You can then store that in a variable for use.  I am pretty sure this is a UNIX command only.  Not sure if this will work in windows or not.  Here is how you use it.

< ?php
$a = `ls -l`;
echo $a;
?>


One comment to “Backtick Operator”


  1. Wes said:

    Yes it does work on windows. The only problem is when trying to use cmd.exe on server, there are permissions issues, which I have not figured out how to get around yet.

Leave a Reply