I want the PHP equivalent of the solution given in to assign the value of a shell variable using the return value of a function from Python
In my php file, I read some constant values, for example:
$neededConstants = array("BASE_PATH","db_host","db_name","db_user","db_pass"); foreach($neededConstants as $each) { print constant($each); }
And in my shell script, I have this code: -
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: ab getConfigVals
I can execute the file through the shell correctly.
To read in more detail what I'm trying to do, check out The cleanest way to read configuration settings from a PHP file and load all project code using a shell script
Update
Fixed configs=getConfigVals replaced by getConfigVals
configs=getConfigVals
getConfigVals
Decision
As Frici answered, he works with this modification: -
PHP code is
function getConfigVals() { php $PWD'/developer.php' #return $collected #echo "done - "$PWD'/admin_back/developer/developer.php' }
shell code -
result=$(getConfigVals) echo $result
You need to execute the function and assign what is printed for this variable:
configs=$(getConfigVals)
See the man page for this shell for more;)
Source: https://habr.com/ru/post/918183/More articles:https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/918178/when-saving-recorded-video-that-is-too-long-app-crashes&usg=ALkJrhjhVYWJVmrwbKZunAHKOzFwOFMDHwStrict 24 hour time in JFormattedTextField - javaHow can I assign a variable using $ pect_out in TCL / EXPECT? - regexRemoving empty directories with msbuild - msbuildPython unicode special character issues - pythonThe cleanest way to read configuration settings from a PHP file and load all project code using a shell script - phpArray Manipulation (printed by php-cli) in a shell script - arraysHow to view the values stored in a list? - containsInitiation of dynamic variables (variable variables) in a bash shell script - variablesjQuery mobile preload page loading content via Ajax - jqueryAll Articles