PHP scripts run on the server (Pre-serve). JS runs on the client(Post-serve). You can't do that. Just re-think your approach, whatever it is that you're trying to do, instead of ugly-thinking your way through.
But what you can do is, call an alternative .php page with some arguments via JS. You can not, in any way, run PHP code in-line within JS.
Hi Guest we just wanted to alert you to a major change in the forum. We will no longer be allowing the posting of outgoing links. Please use the attachment feature to attach media to your posts.