There are only so many languages with which you can build a web application. Two of the most popular are PHP and JavaScript and with one running on the server-side and one running on the client-side, they work well together when creating Ajax requests.
But working the available functions, classes, and libraries for each language can become challenging especially when trying to keep track of how to do a given task in each language.
PHP.js attempts to mitigate that challenge:
If you want to perform high-level operations on these platforms, you probably need to write JS that combines its lower-level functions and build it up until you have something useful like: strip_tags(),strtotime(), number_format(), wordwrap().
That’s what we are doing for you.
Cool, right?
You can browse the available function list (and it’s growing!) here. For questions, and answers, be sure to check out the documentation.
Brian Notess says
I’m trying to figure out if this makes my life more or less complicated.
Writing PHP functions in javascript syntax seems like it would be confusing, at least initially.
I still want to try it out though.
Tom McFarlin says
The syntax should be roughly the same since they’re both C-style languages.
For me, the challenge is separate object-oriented programming from functional programming. For example, given a string s, OO would say s.split(pattern) but functional then says split(pattern, s);
Good thing for documentation, right? 🙂
Brian Notess says
Syntax probably isn’t the right word. I just meant writing
var newrul = urlencode(variable + “appending.this”);
as opposed to
$newurl = urlencode($variable . “appending.this”);
if that makes sense. Probably not.
Tom McFarlin says
Oh! Yeah – makes total sense :).
Not gonna lie – I find PHP to be one of the worst languages when it comes to aesthetic. Honestly, JavaScript isn’t far behind but certain things about it make more sense (such as ‘+’ for concatenation versus ‘.’).