title: Display multiline command output in php
body: <p>In php I wish to display the result of a command output just as it would be shown on the console.  To simplify this example we'll use ifconfig.  The problem is php runs all lines together instead of dispaying it properly.  I have tried to use shell_exec(), passthru(), and system() but they all display the same.</p>
  
  <p>Using these two question as a reference I though passthru() would be the answer.</p>
  
  <p><a href="https://stackoverflow.com/questions/732832/php-exec-vs-system-vs-passthru">PHP - exec() vs system() vs passthru()</a></p>
  
  <p><a href="http://www.sitepoint.com/forums/showthread.php?525977-multiline-result-in-exec" rel="nofollow noreferrer">http://www.sitepoint.com/forums/showthread.php?525977-multiline-result-in-exec</a></p>
  
  <p>Here is the php code:</p>
  
  <pre><code> &lt;?php
      $output = passthru("ifconfig");
      echo $output;
   ?&gt;
  </code></pre>
  
  <p>This is what is displayed in the browser:
  <a href="https://i.stack.imgur.com/wgZ85.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wgZ85.png" alt="enter image description here"></a></p>