with php scripts, remember:
php scripts are server-side. first, a request for a php-scripted page is sent from a browser to the web server. then, the php script runs. it produces an html page (which might contain "sub-languages" such as javascript, vbscript, css).
php finishes generating the page. then, the page code is sent to the browser.
after that, the browser begins to interpret the page with all its enclosed javascript etc.
thus, php runs first, javascript runs last. in the same page, php and javascript cannot interact at runtime!
but, if php can dynamically produce html code, it can dynamically produce javascript code as well - for later client-side execution.
this means, for instance you can make php generate a bunch of java script statements in a loop which are to execute later, after php has finished.
i hope this is what you meant.
(there's server-side javascript as well but I don't suppose you meant that. this would be an equivalent to php.)