This is my workflow:
ubuntu$ cat test.sh
#!/bin/bash
function getNumber
{
echo 1
}
ubuntu$ cat test.php
<?php
echo shell_exec("getNumber");
ubuntu$ source test.sh
ubuntu$ getNumber
1
ubuntu$ php test.php
sh: 1: getNumber: not found
Is it possible to change a php script (or may be its call) the way, so it will print "1"? I am looking for a way to call a bash function from php.
I've tried some solutions from here: Is it possible to source a *.sh file using PHP CLI and access exported Env vars in the PHP script?
One of them was: ./test.sh && php -f test.php
- but no luck.