You can write PHP code within bash script and take advantage of both worlds!
#!/bin/sh
echo This is the Bash section of the code.
amount=5
/usr/local/bin/php -q << EOF
\$myVar = "PHP";
print("This is the \$myVar section of $amount the code.\n The value of the variable amount is $amount \n");
?>
EOF
The output will look something like this...
# sh testphp.sh
This is the Bash section of the code.
This is the PHP section of 5 the code.
The value of the variable amount is 5
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.