Thorazine 10mg Online
Manage EC2 though AWS Management Console »
  • 8th January 2009 - By Vinu Thomas

    PHP.JS Logo

    PHP programmers usually have to handle HTML & Javascript front-end coding as well and I’m sure a lot of us have been frustrated with the lack of those easy to use PHP functions in Javascript like those array, encode/decode and string functions. Here’s a Javascript project which provides you just that.

    PHP.JS is an open source project started by which aims at providing the standard PHP functions for Javascript development. This eases up programming in Javascript for PHP developers as they can use functions they are familiar with. Currently the project has ported around 230+ PHP functions.

    To use this library all you need to do is to download the php.js file and include it in your page:

    <script src="/pathto/php.js"></script>

    Then use use the function as you would in PHP. For example if you want to use the urlencode function in Javascript, just use it like this in Javascript


    This should return ‘’. As easy as that !

    Edit: As Kevin mentioned in the comments below, don’t use the entire php.js file in your projects, just use the function you need.

    History of PHP.JS from (

    A developer called Kevin van Zonneveld was once working on a project with a lot of client(JS) / server(PHP) interaction, and he found himself coding PHP functions (like base64_decode & urldecode) in JavaScript to smoothen communication between the two languages.

    He stored the stored the functions in a file called php.js which was included in the project. But even when the project was done, it remained fun trying to port PHP functions to JavaScript and so the library grew.

    Kevin decided to share the little library online, which triggered the enthusiasm of a lot of PHP developers longing for PHP functionality in JavaScript. The project was open sourced in 2008, and many people contributed their own functions in the comments sections of Kevin’s blog.

    It was decided that the library deserved a bigger home, and a face of its own, and so the PHP.JS core team (which at that time also consisted of Michael White, Felix Geisendörfer, Philip Peterson) developed the website

    PHP.JS Home Page
    List of Functions available in PHP.JS
    Download PHP.JS

    Reblog this post [with Zemanta]
  • 4 Comments to “PHP functions in Javascript using PHP.JS”

    • Kevin van Zonneveld on January 9, 2009

      I would currently not recommend including the entire php.js file in your projects.

      Just use the functions you need.

      We are working on a tool that let’s you compile your own PHP.JS version though, keep an eye on my blog if you want to be notified when we launch it.

    • vinu on January 10, 2009

      Thanks for the heads up Kevin. Will keep an eye out for the compile tool.

    • Thejesh GN on January 21, 2009

      That is a cool JS tip. I am going to use it heavily.

    • [...] return ‘’. As easy as that !Edit: As Kevin mentioned in the comments below, don’t use the entire php.js file in your projects, just use the function you need.History [...]

    Leave a Reply