You sort-of can... but it doesn't really make sense to because you could just do the same thing in PHP if you're doing it server-side anyway. I'd keep JS for client-side stuff.