title: Javascript value undefined when passing from PHP
body: <p>UPDATE: Thank you everyone who helped out. I hope the myriad of solutions on here can serve as a reference for anyone who is facing similar difficulties. </p>
  
  <p>I am reading from a text file with PHP and I need to pass the string into JS for manipulation. I tried the more direct way of placing the PHP into my external JS file, but that didn't work so I'm resorting to using an empty div container. However, in JS I'm still getting an undefined value. The file reads correctly into the div value, it just won't pass to my external javascript file.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;?php
      $world = file_get_contents('http://url.com/testworld.txt');
      //echo $world;
  ?&gt;
  
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/game.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body onload="init()"&gt;
          &lt;canvas id="game" width="650" height="366" style="border: 2px solid black;"&gt;&lt;/canvas&gt;
          &lt;br /&gt;
          &lt;h1&gt; Currently in development.&lt;/h1&gt;
          &lt;br /&gt;
          &lt;div id="world" value="&lt;?php echo $world; ?&gt;" /&gt;
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>And the JS:</p>
  
  <pre><code>var world = document.getElementById('world').value;
  
  document.write(world);
  </code></pre>
  
  <p>If there is a way to make just pulling the variable from the PHP in an external javascript file work, I would prefer to do that. </p>