title: How to debug popen() not working?
body: <p>On my Linux server I use <code>shell_exec()</code> to run scripts asynchronously. This function is not available on Windows, which I use for development, and so I am trying to use <code>popen()</code> instead.</p>
  
  <p>I am running Windows 10 x64, WampServer 2.5 x32 (PHP 5.5.12).</p>
  
  <p>I have the following code in a PHP file:</p>
  
  <pre><code>$cmd = '"C:\wamp\bin\php\php5.5.12\php.exe" "C:\wamp\www\path\to\file.php" "arg1" "arg2"';
  
          echo 'Running on DEV MACHINE: ' . $cmd . PHP_EOL;
          $handle = popen("start /B " . $cmd, "r");
          if ($handle === FALSE) {
              die("Unable to execute $cmd");
          }
          pclose($handle);
  </code></pre>
  
  <p>The script executes without any errors, but the PHP files are never run. I know they aren't being run because I put an SQL query at the very top to update a field in a database to indicate they have been run.</p>
  
  <p>As you can see in the above code, I print out the command being passed to <code>popen()</code>. If I paste that command into command prompt and execute it, the scripts run fine. This proves the issue lies with <code>popen()</code>.</p>
  
  <p>Am I using <code>popen()</code> incorrectly somehow? How can I debug what the problem is? Normally I would debug using XDebug, but there's no way to use that in this situation.</p>