Variables in shell_exec() script

久未见 提交于 2020-01-06 01:58:08

问题


Is there any possible way to make this simple script function properly?

<?php
$hi = "echo hi";
shell_exec($hi);
echo "<pre>$output</pre>";
?>

please help me out?


回答1:


Sure just assign the variable.

<?php
$hi = "echo hi";
$output = shell_exec($hi);
echo "<pre>$output</pre>";
?>



回答2:


$hi = "echo hi";
# the result needs to be assigned to $output before using it
$output = shell_exec($hi);
echo "<pre>$output</pre>";


来源:https://stackoverflow.com/questions/7800687/variables-in-shell-exec-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!