title: Include from "php://memory" stream
body: <p>I'm writing a system for a browser application that will store some particular php scripts in a database and then pull them out and execute them when needed. At first I tried using exec() and piping to php the output of a script that got the scripts out of the database and printed them. This worked in one use case, but not all, and feels brittle anyway, so I'm looking for a better way.</p>
  
  <p>I'm now attempting to accomplish this through use of a PHP file stream in memory. For instance:</p>
  
  <pre><code>$thing = &lt;&lt;&lt;'TEST'
  &lt;?php
  
  $thing = array();
  
  print "Testing code in here.";
  var_dump($thing);
  
  ?&gt;
  TEST;
  
  $filename = "php://memory";
  
  $fp = fopen($filename, "w+b");
  fwrite($fp, $thing);
  //rewind($fp);
  
  fclose($fp);
  
  include "php://memory";
  </code></pre>
  
  <p>However, nothing is printed when the script is executed. Is this even possible by this means, and if not, is there another way to do this? I'm trying to avoid having to write temporary files and read from them, as I'm sure accessing the filesystem would slow things down. Is there a URL I can provide to "include" so that it will read the memory stream as if it were a file?</p>
  
  <p>I don't think <code>eval()</code> would do this, as, if I remember correctly, it's limited to a single line.</p>
  
  <p>Also, please no "eval = include = hell" answers. Non-admin users do not have access to write the scripts stored in the database, I know that this needs special treatment over the life-cycle of my application.</p>