Originally Posted by martynball
I want to define aload of variables as the page loads and then have them loaded into the right elements, without the need of something like this:
I can understand the desire, but PHP and JS produce output in totally different environments. PHP just writes to the output stream (which goes most of the times into the HTTP Response) while JS usually does not have a direct output stream* but has to modify a model (the DOM) in an application (the browser) that renders the visible result.
if you compare PHP with the Node JS application (also server software), the differences are much less. Node can write output via
(to the server terminal) and
(to the HTTP Response), much like PHP is using echo
* - you could see the
interface as direct output stream, though.