Why choose between PHP and JavaScript when you can write code in CASSIS, a language that runs in the syntactical intersection of both languages?
For example:
if (js()) {
/* javascript */
}
else {
/* PHP */
}
https://github.com/tantek/cassis