Trevor Rudolph
Trevor Rudolph

Reputation: 1063

Variables in shell_exec() script

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?

Upvotes: 1

Views: 1024

Answers (2)

Allan MacGregor
Allan MacGregor

Reputation: 924

Sure just assign the variable.

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

Upvotes: 3

sidyll
sidyll

Reputation: 59287

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

Upvotes: 1

Related Questions