我想要与assigning value to shell variable using a function return value from Python中给出的解决方案相当的PHP
$neededConstants = array("BASE_PATH","db_host","db_name","db_user","db_pass");
foreach($neededConstants as $each)
{
print constant($each);
}
function getConfigVals()
{
PHP $PWD'/developer.PHP'
//How to collect the constant values here??
#echo "done - "$PWD'/admin_back/developer/developer.PHP'
}
cd ..
PROJECT_ROOT=$PWD
cd developer
# func1 parameters: a b
getConfigVals
我能够正确地通过shell执行文件.
要进一步阅读我想要做的事情,请查看Cleanest way to read config settings from PHP file and upload entire project code using shell script
更新
更正了configs = getConfigVals替换为getConfigVals
解
正如Fritschy所回答的,它适用于这种修改: –
function getConfigVals()
{
PHP $PWD'/developer.PHP'
#return $collected
#echo "done - "$PWD'/admin_back/developer/developer.PHP'
}
shell代码 –
result=$(getConfigVals)
echo $result
解决方法:
configs=$(getConfigVals)
有关更多信息,请参阅扩展时该shell的联机帮助页;)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。