title: Writing HTML that contains PHP tags to file
body: <p>I think what I'm trying to do must be impossible; incredibly difficult; or pretty easy, and I just don't know how to express what I want correctly to Google.</p>
  
  <p>What I want to do is the following:</p>
  
  <p>For the purposes of templating, I am outputting HTML to a file.  However, I want the file to contain PHP tags - not the parsed value of the PHP code (this value will change based upon included scripts in the output file) - but the actual <code>&lt;?php ?&gt;</code> tags themselves - containing the unmodified code, such that the code is still executable at run time.</p>
  
  <p>This is an example of what I want to get outputted:</p>
  
  <pre><code>&lt;html&gt;
        &lt;body&gt;
          &lt;img src="&lt;?php echo IMG_PATH;?&gt;img.jpg" /&gt;
        &lt;/body&gt;
     &lt;/html&gt;
  </code></pre>
  
  <p>What I'm getting is a combination of things that are wrong, depending on which method I use.  Basically, I need to be able to write parsable PHP code to a HTML file.  Now, whether or not this is a good idea is debatable, and a subject I'm not too interested in at the moment.  I just want to know if a <strong>sane</strong> solution exists.</p>
  
  <p>I came up with the following <strong>insane</strong> solution:</p>
  
  <pre><code>$content='&lt;html&gt;&lt;body&gt;&lt;img src="zxzxzx?php echo IMG_PATH; ?qjqjqj" /&gt;';
  file_put_contents($file,$content);
  
  $command='perl -p -i.bktmp -e "s/zxzxzx/&lt;/g" '.$file.' 2&gt;'.$path.'error.log';
  $command2='perl -p -i.bktmp -e "s/qjqjqj/&gt;/g" '.$file.' 2&gt;'.$path.'error.log';
  exec($command);
  exec($command2);
  </code></pre>
  
  <p>Now, on one hand, this feels devilishly clever.  And, it also feels insane.  Is there a better/possible way to do this?</p>