I'm writing a web app using PHP, and running into several situations where I need similar code on the server and browser. For example:
It seems like this should be a common problem, as people are moving more logic from the server to the browser. But are there any common patterns or libraries for dealing with it (particularly for PHP)?
One solution would be to use server-side JavaScript. You'd be able to share huge chunks of code then.
Interesting question! As far as I know there are 2 options for PHP:
In Java however, you can run Javascript with Rhino.
The other things I can think of are ugly hacks with Flash or Java applets, or involve a framework like Pyjamas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With