$myValue doesn't matter when trying to use it in JS.
PHP runs on the server, outputs an HTML document with embedded JavaScript, the document is sent to the client, and then JavaScript is executed.
If you do not know what value a JavaScript variable should have until PHP reaches the end of the document, you will not be able to generate this part of JS until then. You probably want to write it as an argument instead of calling a function.
Once you do this, you will have another problem - if your data is a string, then you need to specify it (and any corresponding quotation marks inside it must be escaped).
In a nutshell: PHP displays text that can be processed as JS, it cannot call JavaScript functions (unless you start mixing extensions that can talk to Rhino / Spidermonkey / etc on the server).
All that said, in this case, there seems to be no reason to use JavaScript in the first place, and you would be better off moving all the logic to PHP.
By the way, your choice of Doctype will trigger Quirks mode in most browsers. This is almost always very undesirable.
The best choice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Or if you really want Transitional:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
source share