I am trying to run a PHP function inside Bash... but it is not working.
#! /bin/bash
/usr/bin/php << 'EOF'
<?php echo getcwd(); ?>
EOF
In the reality, I needed to keep the return value in a bash variable... By the way, I am using the php's getcwd() function only to illustrate the bash operation.
UPDATE: Is there a way to pass a variable?
VAR='/$#'
php_cwd=`/usr/bin/php << 'EOF'
<?php echo preg_quote($VAR); ?>
EOF`
echo "$php_cwd"
Any ideas?
php_cwd=`/usr/bin/php << 'EOF'
<?php echo getcwd(); ?>
EOF`
echo "$php_cwd" # Or do something else with it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With