According to the php manual, the function pcntl_exec is equal to the syscall execve.
So I think
pcntl_exec("/bin/sh", ["/bin/sh"]);
should do the same thing like:
#!/bin/sh
/bin/sh
However I got the result: # /bin/sh: 1: Syntax error: ")" unexpected
Why?
php version 7.4.3(cli) Zend Engine v3.4.0
This is incorrect:
It is equivalent to running the command
/bin/sh /bin/shwhich will attempt to interpret/bin/shas a shell script.The actual equivalent of what you want would be: