2011-10-17 15 views
1

この単純なスクリプトを適切に機能させる方法はありますか?shell_exec()スクリプト内の変数

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

私を助けてください?

+0

'shell_exec($ hi);' $ 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>"; 
関連する問題