No, it doesn't work like that PHP runs on the server, and what it produces goes to the client, which is where the Javascript runs.
What you can do is use PHP to write Javascript, and so customise the script that gets served up - passing variables from PHP to Javascript is just the start.
<?php
Some PHP code here
echo "<script language=\"Javascript\">";
echo "function {
....echo some more Javascript stuff...
echo "</script>";
More PHP code here.
?>
To pass a PHP variable's value into Javascript it's just a matter of
echo "var jsvar='$phpvar';";
If $phpvar has the value 'Marvin' at that point, then what the browser gets for its Javascript includes the line
var jsvar='Marvin';
The Crucial thing to remember is: The Javascript in an html file is just text, just like the rest of the file. You can have PHP write it however you want.