I am running bash scripts from PHP page. I am using XAMPP server on localhost. using these commands:
$contents = file_get_contents('../scripts/simple.sh');
$output = null;
$return_var = null;
$contents = escapeshellarg($contents);
exec("bash -c $contents 2>&1", $output, $return_var);
I added this command to my bash script to see which version is running:
bash --version
When I run the bash script from the terminal using ./simple.sh it uses bash version:
GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin18.7.0)
However, when I run it from PHP page it uses :
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
How could I force PHP to use bash version 4.0 or newer?
note: I also tried exec("/usr/local/bin/bash -c $contents 2>&1", $output, $return_var); and got the same output as above