I believe the title speaks for itself but I will elaborate a little more. I have a php file called hello-world.php. I also have a bash script called testBash.sh.
Inside of hello-world.php I have two methods helloWorld() and helloName($name)
Basically what I want to do is from within my bash script (testBash.sh) ... I want to pass in the parameter and execute the helloName($name) method. The parameter will be given from within the bash script.
Here is what I have so far.
testBash.sh
INPUT="Bobby"
// THIS IS WHERE I AM HAVING TROUBLE
TEST= php -r "require 'hello-world.php'; helloName("$INPUT");"
echo "$TEST"
hello-world.php
function helloWorld() {
return "Hello, World!";
}
function helloName($name) {
return "Hello, $name!";
}
In a perfect world when I echo "$TEST" the results of that function should be displayed.
Ex: Hello, Bobby!
Is this possible? I have looked online for solutions but this is the closest I have come to find one. Any input or advice would be great. Thanks!
TEST=$(php -r "require 'hello-world.php'; echo helloName(\"$INPUT\");")? Not on a linux computer atm so can't test.