php.js - Javascript equivalents for PHP functions

Being a PHP developer, there must be certain times when you have to deal with Javascript. And if you’re rather confident with PHP when in the meantime suck at JS just like me, you must have more than once googled for the JS equivalent of that very useful/powerful base64_encode, or htmlentities, or array_merge, or strpos, you_name_it.

Well, I’m not any exception, until I got acknowledged of a JS project called php.js originally started by Kevin van Zonneveld. I have used this in more than one of my projects and it just works perfect for me without any hassles, so maybe I should feature it in return.

You can tell, the project is all about porting PHP functions into Javascript. Yes, many of those are there, but under a different name or one step away - like PHP’s sin and JS’ Math.sin. Some others however, are not that easy to obtain in Javascript - I’m talking about md5, date, serialize etc. and those array stuffs. It even deals with file system, with the support of the XMLHttpRequest object (therefore these functions may fail if the browser doesn’t support it).

The project is active and it seems Kevin, with the great help from other contributors, is constantly expanding it. A list of available (successfully ported) methods can be found here - nearly 300 (!) each with detailed code and examples. You can just copy the function code and embed it into your script to start using right away, or download the full packages for everything.

I, for myself, can’t understand how there are such good people in this world: put huge effort into something just to give away, expecting nothing in return.

Are you using of this wonderful project in your own? If so how about featuring it?

  • I use some of those functions all the time on different projects - I wrote a compiler a while back to be able to select individual functions and shrink them into a custom file.  Since then Kevin standardized the functions and I think he has rebuilt the compiler. I found that including all functions took up too much browser memory to really be efficient - but the project as a whole has tremendous use.

  • It seems nice, maybe I’ll contribute a bit with this framework because I love JavaScript as well as PHP.

You can follow any responses to this entry through the RSS 2.0 feed.