I need to write some PHP code inside a Javascript\'s \"document.write()\". This is a dummy example, but in the future Javascript will generate automatically tha
It's impossible. Php need server-side to runs, and javascript runs just on client side.
What you can do is prepare one php code to write one file and call this code by javascript.