Right, you've answered your own question: Yes, you can!
BUT... You're really mixing up everything here. I recommend you try Smarty (
http://www.smarty.net/ ) and keep your pages separated in three files:
- page.php - contains the _php code_, initializes the smarty object and sets variables, includes page.tpl
- page.tpl - contains the html code mixed with _smarty templates_ and includes the javascripts required
- page.js - contains the _javascript code_
If you don't split things up, you'll mash everything up and it will be impossible for anyone to understand what you are doing. Using PHP to echo JavaScript code so that it would come out in the HTML page is just awful :o)