问题
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