Your call is failing because you're using a web-style syntax (?parameter=value) with a command-line invokation. I understand what you're thinking, but it simply doesn't work.

You'll want to use $argv instead. See the PHP manual.

To see this in action, write this one-liner to a file:

<?php print_r($argv); ?>

Then invoke it from the command-line with arguments:

php -f /path/to/the/file.php firstparam secondparam

You'll see that $argv contains the name of the script itself as element zero, followed by whatever other parameters you passed in.

Answer from Chris Allen Lane on Stack Overflow
🌐
PHP
php.net › manual › en › function.exec.php
PHP: exec - Manual
If you do not want the function to append elements, call unset() on the array before passing it to exec(). ... If the result_code argument is present along with the output argument, then the return status of the executed command will be written to this variable.
🌐
Team Treehouse
teamtreehouse.com › community › php-exec-function-passing-a-value-to-command-line
PHP exec function passing a value to command line (Example) | Treehouse Community
October 1, 2014 - ... You need to use the $argv variable built in to PHP. Exec() method emulate the command line, meaning exec("example.php") works the same as php -f example.php on the command line.
🌐
Scaler
scaler.com › home › topics › php exec() function
PHP exec() Function - Scaler Topics
March 18, 2024 - It allows you to pass command arguments and options as separate parameters. shell_exec(): The shell_exec() function executes commands within the context of a shell, which provides more flexibility and allows the use of shell features, such as ...
🌐
GitHub
github.com › wkhtmltopdf › wkhtmltopdf › issues › 2909
PHP exec() url with parameters · Issue #2909 · wkhtmltopdf/wkhtmltopdf
April 27, 2016 - exec(C:\folder\wkhtmltoimage.exe "http://localhost/webpage.php?p1=276&p2=325" C:\test\1.png); also tried with no luck exec('C:\folder\wkhtmltoimage.exe "http://localhost/webpage.php?p1=276&p2=325" C:\test\1.png'); exec(cmd.exe /c C:\folder\wkhtmltoimage.exe "http://localhost/webpage.php?p1=276&p2=325" C:\test\1.png); exec('cmd.exe /c C:\folder\wkhtmltoimage.exe "http://localhost/webpage.php?p1=276&p2=325" C:\test\1.png'); despite the following works excellent exec(C:\folder\wkhtmltoimage.exe http://www.google.com C:\test\1.png); The first one works also well from Command Prompt.
Author   wkhtmltopdf
🌐
Medium
lakin-mohapatra.medium.com › achieve-parallel-processing-in-php-using-shell-exec-af99857d023c
Achieve parallel processing in php using shell_exec() | by Lakin Mohapatra | Medium
December 25, 2021 - // Set data which needs to be passed to separate process running php file. $arguments = [ 'data' => [], 'msg' => 'Test Message'];// Set Redirect output path to run php file in background rather than waiting for its output.
Find elsewhere
🌐
Linux Hint
linuxhint.com › execute_shell_command_php
Execute Shell Command in PHP using exec() – Linux Hint
The following example shows the use of optional arguments of the exec() function. Create a PHP file with the following script. Two optional arguments of exec() are used in this script. ‘ls -l‘ command is used in the first argument that returns the list of directories.
🌐
Igor's Blog
igorkromin.net › index.php › 2017 › 12 › 07 › how-to-pass-parameters-to-your-php-script-via-the-command-line
How to pass parameters to your PHP script via the command line | Igor Kromin
December 7, 2017 - First with getopt() you must specify which command line argument you want to retrieve. In the case of this script, it looks for the "-p" argument, that's specified by the "p:" value passed to getopt(). The colon (:) means that the parameter must have a value. If you're used to doing something like "script.php?p=value1" this is an equivalent for the command line.