title: Saving data as a PHP script / as a .php file? (Purely theoretical)
body: <p>I know this would be all kinds of bad form, but am curious as to whether or not this would work.</p>
  
  <p>Let's say I'm a total hopeless case who doesn't know a thing about SQL, so normally I go saving all my data as .txt files (which, sadly, was true of me until not-so-long-ago).</p>
  
  <p>I know that if someone were to stumble upon the URL of one of these .txt files, they'd (obviously) be able to see all the data inside it. So I think, "What if I saved the data inside a PHP script/file? That way if anyone stumbles across it they'll just see a blank page because the server will execute it as PHP."</p>
  
  <p>So here's the ultra-confidential array of data I want to save:</p>
  
  <pre><code>$myArray = array("apple","orange","banana");
  </code></pre>
  
  <p>I take this array and do this:</p>
  
  <pre><code>file_put_contents("data.php", "&lt;?php \$var=\"" . htmlentities(json_encode($myArray)) . "\"; ?&gt;");
  </code></pre>
  
  <p>The result is a file called "data.php" that contains one line of code:</p>
  
  <pre><code>&lt;?php $var="[&amp;quot;apple&amp;quot;,&amp;quot;orange&amp;quot;,&amp;quot;banana&amp;quot;]"; ?&gt;
  </code></pre>
  
  <p>This file is invisible to any outside users; it's valid PHP code and the server executes it as such, but all it does is declare a variable.</p>
  
  <p>However, I can access the data recorded in data.php from another file by doing this:</p>
  
  <pre><code>$importVar = htmlentities(file_get_contents("data.php"));
  $importVarBeg = 20;
  $importVarEnd = 13;
  $importVar = html_entity_decode(substr($importVar, $importVarBeg, strlen($importVar) - ($importVarBeg + $importVarEnd)));
  $importVarArray = json_decode(html_entity_decode($importVar));
  </code></pre>
  
  <p>Now <code>$importVarArray</code> contains my original super-confidential data array, to do with as I please!</p>
  
  <p>So again, I know this is a really stupid way to do things, but stupidity aside, is it actually a viable way of storing data such that it's totally inaccessible to outside users?</p>
  
  <p>EDIT: Clarifying "outside user" -- anyone hitting my website. Let's say I'm the only person using my server.</p>