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.
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.
HTML:
<?php
$world = file_get_contents('http://url.com/testworld.txt');
//echo $world;
?>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="js/game.js"></script>
</head>
<body onload="init()">
<canvas id="game" width="650" height="366" style="border: 2px solid black;"></canvas>
<br />
<h1> Currently in development.</h1>
<br />
<div id="world" value="<?php echo $world; ?>" />
</body>
</html>
And the JS:
var world = document.getElementById('world').value;
document.write(world);
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.
someNullExpression.innerHTMLwhich is can not be the result of the code posted above as there is noinnerHTML.