is a microblog
home archives search feed blogroll

The Execution Operator

PHP will execute content between backticks as shell commands. The result can be assigned to a variable.


$result = `ls`;
echo $result;

Variables can be used within the execution operator.


`git init`;
`git add .`;

$message = 'Use execution operator';
`git commit -m "{$message}"`;

This is also known as the backtick operator. It’s disabled when safe_mode is enabled or shell_exec() is disabled.

Posted on 2018-01-15   #til     #php  

← Next post    ·    Previous post →