How would you get the string output of the current shell in PHP?
This is what I tried
$output = shell_exec('echo $SHELL 2>&1');
but I'm getting empty output when I print it out.
$output should be a string that is something like /bin/bash
There is an specific function for getting environment variable values
that you can use: getenv():
echo getenv('SHELL');
2>&1to the command, which OP already has. It is not a duplicate for that question.