title: Call PHP script from another with arguments and get output
body: <p>I have a php script, let's call it <code>one.php</code>. This calls a second php script <code>two.php</code> with some arguments. Right now my code in <code>one.php</code> looks like this:</p>
  
  <pre><code>shell_exec("php ./two.php" . ' ' . escapeshellarg($var1) . ' '.      
  escapeshellarg($var2) . ' '. escapeshellarg($var3));
  </code></pre>
  
  <p>This works fine (although I don't like it), but now I want to get some values that are computed in <code>two.php</code>. </p>
  
  <p>I colud use <code>include()</code> or <code>require()</code> to get access to all the variables, but I want to use <code>two.php</code> in more than just one script - without having to use the same variable names in every script that calls <code>two.php</code> (which I had to because of the scope of the variables in <code>include()</code>).</p>
  
  <p>My php skills are quite poor, so: Is there a way to send variables of a called script to the calling script or something like this? Or maybe another way of calling <code>two.php</code>.</p>
  
  <p><strong>Update</strong>: Using a function did it. Thanks!</p>