I want to pass variables from bash to php in 1 script. I know it's possible with 2 files and $argv in the php, but I would really like to put the script in 1 file. This is what i got now:
#!/bin/bash
echo "This is bash"
export VAR="blabla"
/usr/bin/php << EOF
<?php
echo getenv("VAR");
?>
EOF
which works fine. But there is one problem: i can't seem to store the getenv in a variable.
#!/bin/bash
echo "This is bash"
export VAR="blabla"
/usr/bin/php << EOF
<?php
$var = getenv("VAR");
echo $var;
?>
EOF
Gives me this error: PHP Parse error: syntax error, unexpected '=' in - on line 3
I get the same error if i even try to define a basic variable like $var = "hello";