2011-10-17 46 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>";