Programmer's Wiki

This scratchpad is intended for preparing a JavaScript library which mimics the API of PHP. This is intended to make it easier for PHP developers to use just one familiar API for functions (albeit relying on JavaScript syntax).

The functions may not mirror the exact behavior as found in PHP--either due to insurmountable differences with JavaScript or due to not having been adequately programmed yet (though please help to improve this).

By relying on the PHP interface, we avoid developing yet another library whose API might be too subject to change (though we could update with new versions of PHP). We will only use PHP names, except where an existing JavaScript function of the same name already exists (e.g., "eval"), in which case we will prepend "php_" to the function name.

For I/O and other privileged functions, we could either use Mozilla Javascript and XPCOM and/or Server-side JavaScript (SSJS).

Perhaps an ideal future ambition for the project would be to see some high bandwidth site to host the library (e.g., as Yahoo has done with its AJAX library) so that it could be frequently used and cached by others without fear of the library modules (depending on which set(s) were chosen) taking up too much memory to be useful.

We might also work to add within the PHP section of this Programming wiki, a PHP library to mimic the function/objects/methods/properties of Javascript, prepending "js" and capitalizing the next word (in Javascript style)--e.g., jsEval to avoid conflicts with the PHP function of the name, "eval".

Function libraries[]

Array Functions[]

Cross-reference between Javascript functions and equivalent PHP/PHP-Javascript functions (if any)[]

Javascript PHP/PHP-Javascript equivalent
Array.concat() array_merge()
Array.join() implode()
Array.pop() array_pop()
Array.push() array_push()
Array.reverse() array_reverse()
Array.shift() array_shift()
Array.slice() array_slice()
Array.sort() sort()
Array.unshift() array_unshift()

External links[]

  • php.js - An open source project implementing PHP functions in Javascript