2011-10-17 45 views
1

有没有任何可能的方法来使这个简单的脚本功能正常?shell_exec()脚本中的变量

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

请帮我一下吗?

+0

不应该'shell_exec($ hi);'read'$ output = shell_exec($ hi);'? – DaveRandom

+0

thx,我必须不小心删除了一些东西,那就是我原来的东西 –

回答

2

当然,只是分配变量。

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