2011-10-17 7 views
1

Existe-t-il un moyen de rendre cette fonction de script simple?Variables dans le script shell_exec()

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

aidez-moi s'il vous plaît?

+0

ne devrait pas 'shell_exec ($ hi);' lire '$ output = shell_exec ($ hi);'? – DaveRandom

+0

thx, je dois avoir accidentellement supprimé quelque chose, c'est ce que j'avais à l'origine –

Répondre

2

Bien sûr, affectez simplement la variable.

<?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>";