title: PHP / cURL or file_get_contents -- How to get the value of a JS page instead of the JS code
body: <p>This is hopefully an easy question, but it's giving me an issue. I have a page &quot;sample.html&quot; with a simple script like this in JS:</p>
  <pre><code>// sample.html
  &lt;script&gt;
      let myNumber = 15;
      document.write(myNumber);
  &lt;/script&gt;
  </code></pre>
  <p>... and then I want to have a PHP page (&quot;getValue.php&quot;) go and get that number (e.g., 15). My problem is:  If I do a file_get_contents or even a cURL to that JS page, like so...</p>
  <pre><code>// getValue.php
  $newVal = file_get_contents('sample.html');
  </code></pre>
  <p>... the $newVal var in PHP is NOT simply the &quot;15&quot; value. Instead, the var is equal to the entire JS script shown. So, how can I use PHP to get that &quot;15&quot; value alone as a variable?   In other words, I only want $newVar to be the <em>result</em> of the JS page, not the entire script. What I want to achieve is:</p>
  <p>// $newVal == 15</p>