PHP provides several functions for executing shell commands directly from a script. It also supports the backtick operator - known as the execution operator - which runs a command and returns its output so it can be printed or assigned to a variable.
Since PHP 8.5, backtick operator is deprecated. This means that the following code will issue a deprecation warning:
<?php
echo `curl https://httpbin.org/get`;
Example will output:
Deprecated: The backtick (`) operator is deprecated, use shell_exec() instead ...
The backtick operator works the same as shell_exec function, but its purpose is less obvious and can be harder to understand at a glance. In the previous example, a deprecation warning can be resolved as follows:
<?php
echo shell_exec('curl https://httpbin.org/get');
Leave a Comment
Cancel reply