Use PHP functions in JavaScript

php.js

php.js Logo php.js is an open source project that brings high-level PHP functions to low-level JavaScript platforms such as webbrowsers, AIR, V8 and rhino.

If you want to perform high-level operations on these platforms, you probably need to write JS that combines it's lower-level functions and build it up until you have something useful like: md5(), strip_tags(), strtotime(), number_format(), wordwrap().

That's what we are doing for you.

No server component required. To use php.js you can either:

PHP is a language with many high-level functions and while they're not always implemented as consistently as we'd like (mostly to blame on it's underlying C parts), it has a huge following familiar with it's syntax so it makes sense to pick it's API as a reference. Elimating the need for our own documentation, thus making life easier we hope.

We recognize JS - on the other hand - has beautiful language features and we encourage you to learn them. Never let php.js be an excuse not to.
For the same reason, we're not porting entire language or control structures of PHP; we stick with the functions.

Featured Functions

date()
Date-formatting, just like you know it from PHP

base64_decode()
Safe & easy data transport, decode messages in JavaScript that where encoded by PHP.

The History of php.js

Kevin van Zonneveld was once working as devloper on a project with a lot of client(JS) / server(PHP) interaction, and 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.
There was a technological challenge in trying to recreate functions such as date, or sprintf.
Eventually Kevin decided to share the little library on his blog, triggering 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 consisted of Michael White, Felix Geisendörfer, Philip Peterson and Kevin) developed the phpjs.org website.

Different core members have come & gone but there has always been a select group pushing the project forward.

Late 2008 Brett Zamir started contributing and did't stop. In April 2009 he was responsible for over 245 different PHP functions and has had many ideas considering php.js' future.

Because the library became too big to include at once, and having users copy-paste functions to their projects was nothing short of creating a maintenance hell, Kevin started working on a compiler tool that allows programmers to select ONLY the functions they need, and wrap them up in a single php.js file.
This took away overhead and even allowed for easy upgrading.

And that's where we are now.

We are still trying to port and perfect more & more functions.
Want to help out & become a part of php.js history? Why not add a comment with new or better code? It's that easy.

Comments

Add Comment
Use:
[CODE]
your_stuff('here');
[/CODE]
for proper code formatting
By submitting code here you are allowing us to use it in php.js hence dual licensing it under the MIT and GPL licenses

Gravatar
Brett Zamir
Jan 31st Permalink

q  @Marco: Sorry for the delayed reply... Have you seen http://www.php.net/manual/en/tokens.php and also the comments there? There's some reference to whitespace as a tokens...

Gravatar
Marco Marchiò
Jan 28th Permalink

q  Hi, i'm trying to create the token_get_all function and i need help on a little problem.
Do you know when whitespaces (\t,\n,\r and spaces) are considrered tokens?
The orignal PHP function get only some of them but i can't understand which ones.

Gravatar
Brett Zamir
Jan 27th Permalink

q  @cynosure: Hi! Don't mean to be unfriendly, but I imagine Kevin would prefer we limit discussion here to php.js functions. But really quickly, it appears that IE may be (mistakenly) considering the XML Declaration at the beginning of the document as though it were a node (probably considering it a processing instruction which it is not, even though it looks like one)--the declaration info should only be available to the DOM as document.xmlVersion, document.xmlEncoding and document.xmlStandalone , though browser support is unfortunately limited even in Firefox; see http://brettz9.blogspot.com/2009/04/xml-dom-support-test.html ). Thankfully, you can still make cross-browser code here in testing whether the nodeName of a "processing instruction" is "xml"; since processing instructions cannot be "xml", you would know it is the bogus IE one and can be avoided.

You could confirm IE indeed treats it this way by printing out the nodeType as well; see https://developer.mozilla.org/en/nodeType for the codes. Also, your example is not recursive, as if it were, you would also need to check whether the node were an element and then recurse on its children; currently you are only iterating through the top level nodes. Maybe this was a simplified example...

Gravatar
cynosure
Jan 27th Permalink

q   Hi!

I'm working now on an xml parser (not yet on a php type XML API object), but I fount a new funny difference between IE6-8 and any other browsers.

I have a simple XML:

1
2
3
4
56
7
8
<?xml version="1.0" encoding="UTF-8"?>
<main>
    <response>
        <age>6</age>
    </response>    <redirect>
    </redirect>
</main>


When I try to loop the elements in a recursive way, the code above works different in these browsers:

1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
18
19
xml2Array = function(xml)
{
    var nodecount = xml.childNodes.length;
    if(nodecount > 0)
    {        var log = '';
        var arr = new Array();
        for(var i=0;i<nodecount;i++)
        {
            log = log + i + ' -> ' + xml.childNodes[i].nodeName + '';        }
        document.getElementById('foo').innerHTML = log;
    }
    else
    {        var arr = false;
    }
    return arr;
}


In IE writes out:
0 -> xml
1 -> main

In other browsers:
0 -> main

Gravatar
Brett Zamir
30 Dec '09 Permalink

q  Interesting about the delete operator. I knew it didn't work with variables, and imagined it wouldn't work on some built-in objects, but nice to know that formally.

Nice set of examples. It's supposed to get even weirder in IE as far as ordering if you use an object and with properties inherited from the prototype. It's sad that what may be the most usable scripting if not programming language in the world is the least updated. I can live with most of JavaScript's other quirks, even the ease of making accidental globals, but this one should plain and simply just be fixed in the spec and reality.

Gravatar
Brett Zamir
30 Dec '09 Permalink

q  Interesting about the delete operator. I knew it didn't work with variables, and imagined it wouldn't work on some built-in objects, but nice to know that formally.

Nice set of examples. It's supposed to get even weirder in IE as far as ordering if you use an object and with properties inherited from the prototype. It's sad that what may be the most usable scripting if not programming language in the world is the least updated. I can live with most of JavaScript's other quirks, even the ease of making accidental globals, but this one should plain and simply just be fixed in the spec and reality.

Gravatar
cynosure
29 Dec '09 Permalink

q   @Brett Zamir: The delete method have an other issue, it can't remove an element if it have a DontDelete attribute.

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/delete_Operator

In the other hand, associative arrays works in IE6 too, but this is not really an array, this is an object, so .splice won't work in any browsers:

1
2
3
4
56
7
8
9
1011
12
13
14
1516
var foobar = new Array();
foobar['x'] = 'a';
foobar['y'] = 'b';
alert(foobar['x'] + ' ' + foobar['y']); // writes "a b"
// and the problems:alert(foobar.splice('x',1)); // does nothing, writes empty window
alert(foobar.splice(0,1)); // does nothing too
alert(foobar['x'] + ' ' + foobar['y']); // writes "a b" again
// with delete:
delete foobar['x'];alert(foobar['x'] + ' ' + foobar['y']); // writes "undefined b"
for(var key in foobar) { alert(key); } // writes "y"
// let's test the element orders
foobar['x'] = 'c';
alert(foobar['x'] + ' ' + foobar['y']); // writes "c b", its okfor(var key in foobar) { alert(key); } // writes "x" and "y" in IE6-8, "y" and "x" in all other browsers


I know, this is exactly what you wrote, I only made a test to everyone who wants to know how it works.

Gravatar
Brett Zamir
29 Dec '09 Permalink

q   @cynosure: Looks like someone else here tried something similar: http://phpjs.org/functions/array_pop:329#comment_354 .

As far as a reference to an array, whatever value you pass in to a function, if it is an array or object, its elements can be acted on by reference and in fact only by reference unless you manually make a copy (though you cannot replace the whole object with something else, or that does make a copy). So, we could adapt your function to work by reference (though still breaking the PHP API which only uses one argument):

1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
function unset(array,index) {
    if (typeof array === 'object' && typeof array.length == 'number') {
        array.splice(index, 1); // Using the delete operator will replace the old value
        // with "undefined" in its old slot, but we also want to remove the slot itself,
        // so with arrays (in IE too), we can safely use splice().    }
    else { // Objects
        delete array[index]; // For object properties, this works pretty well, except potentially in IE where
        // the property will thankfully no longer be iterated, but it has the annoying feature (for
        // the sake of our using objects to imitate PHP associative arrays) that if you later try to        // add back a value with the same property name, it will put your new value in the old
        // iteration position.  So IE does not truly delete the property, though it may appear that way.
        // All other popular browser implementation seem to truly delete the property (and iterate
        // in order), at least if it is not an inherited property, but the latest ES spec wasn't able
        // to persuade IE to change this behavior    }
}


See the 2nd comment above for the potential problems with this though. Basically in IE, simple objects as associative arrays just won't work perfectly. It is very disappointing. You can get around this by creating an object which wraps your data, but that can get quite ugly. Otherwise, you just have to keep your keys in one array and values in another array.

This is not to speak of our other challenge here of trying to work with only one argument in unset(). JavaScript does not allow us to get the container object or array if we only know the property. Our experimental version of unset() (at http://github.com/kvz/phpjs/blob/master/_experimental/var/unset.js ), allows us to pass in a single argument, but it is a (necessarily) very bad solution as it relies on eval(), and only works on globals passed in as strings. That's a huge compromise just to work with a single argument, so practically speaking, your solution is probably better (though with the above-mentioned caveats).

A similar problem occurs with trying to imitate PHP's extract() and compact(). We don't have a way in JavaScript (unless we exclusively work with globals) to say use the arguments object to obtain or set the local variables of the caller (we can only get access to those variables explicitly passed in as arguments, and only by reference if they are objects or arrays).

I think these may well be the biggest challenges for php.js trying to follow the PHP API.

Gravatar
Brett Zamir
29 Dec '09 Permalink

q   @cynosure: Looks like someone else here tried something similar: http://phpjs.org/functions/array_pop:329#comment_354 .

As far as a reference to an array, whatever value you pass in to a function, if it is an array or object, its elements can be acted on by reference and in fact only by reference unless you manually make a copy (though you cannot replace the whole object with something else, or that does make a copy). So, we could adapt your function to work by reference (though still breaking the PHP API which only uses one argument):

1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
function unset(array,index) {
    if (typeof array === 'object' && typeof array.length == 'number') {
        array.splice(index, 1); // Using the delete operator will replace the old value
        // with "undefined" in its old slot, but we also want to remove the slot itself,
        // so with arrays (in IE too), we can safely use splice().    }
    else { // Objects
        delete array[index]; // For object properties, this works pretty well, except potentially in IE where
        // the property will thankfully no longer be iterated, but it has the annoying feature (for
        // the sake of our using objects to imitate PHP associative arrays) that if you later try to        // add back a value with the same property name, it will put your new value in the old
        // iteration position.  So IE does not truly delete the property, though it may appear that way.
        // All other popular browser implementation seem to truly delete the property (and iterate
        // in order), at least if it is not an inherited property, but the latest ES spec wasn't able
        // to persuade IE to change this behavior    }
}


See the 2nd comment above for the potential problems with this though. Basically in IE, simple objects as associative arrays just won't work perfectly. It is very disappointing. You can get around this by creating an object which wraps your data, but that can get quite ugly. Otherwise, you just have to keep your keys in one array and values in another array.

This is not to speak of our other challenge here of trying to work with only one argument in unset(). JavaScript does not allow us to get the container object or array if we only know the property. Our experimental version of unset() (at http://github.com/kvz/phpjs/blob/master/_experimental/var/unset.js ), allows us to pass in a single argument, but it is a (necessarily) very bad solution as it relies on eval(), and only works on globals passed in as strings. That's a huge compromise just to work with a single argument, so practically speaking, your solution is probably better (though with the above-mentioned caveats).

A similar problem occurs with trying to imitate PHP's extract() and compact(). We don't have a way in JavaScript (unless we exclusively work with globals) to say use the arguments object to obtain or set the local variables of the caller (we can only get access to those variables explicitly passed in as arguments, and only by reference if they are objects or arrays).

I think these may well be the biggest challenges for php.js trying to follow the PHP API.

Gravatar
Brett Zamir
29 Dec '09 Permalink

q   @cynosure: Looks like someone else here tried something similar: http://phpjs.org/functions/array_pop:329#comment_354 .

As far as a reference to an array, whatever value you pass in to a function, if it is an array or object, its elements can be acted on by reference and in fact only by reference unless you manually make a copy (though you cannot replace the whole object with something else, or that does make a copy). So, we could adapt your function to work by reference (though still breaking the PHP API which only uses one argument):

1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
function unset(array,index) {
    if (typeof array === 'object' && typeof array.length == 'number') {
        array.splice(index, 1); // Using the delete operator will replace the old value
        // with "undefined" in its old slot, but we also want to remove the slot itself,
        // so with arrays (in IE too), we can safely use splice().    }
    else { // Objects
        delete array[index]; // For object properties, this works pretty well, except potentially in IE where
        // the property will thankfully no longer be iterated, but it has the annoying feature (for
        // the sake of our using objects to imitate PHP associative arrays) that if you later try to        // add back a value with the same property name, it will put your new value in the old
        // iteration position.  So IE does not truly delete the property, though it may appear that way.
        // All other popular browser implementation seem to truly delete the property (and iterate
        // in order), at least if it is not an inherited property, but the latest ES spec wasn't able
        // to persuade IE to change this behavior    }
}


See the 2nd comment above for the potential problems with this though. Basically in IE, simple objects as associative arrays just won't work perfectly. It is very disappointing. You can get around this by creating an object which wraps your data, but that can get quite ugly. Otherwise, you just have to keep your keys in one array and values in another array.

This is not to speak of our other challenge here of trying to work with only one argument in unset(). JavaScript does not allow us to get the container object or array if we only know the property. Our experimental version of unset() (at http://github.com/kvz/phpjs/blob/master/_experimental/var/unset.js ), allows us to pass in a single argument, but it is a (necessarily) very bad solution as it relies on eval(), and only works on globals passed in as strings. That's a huge compromise just to work with a single argument, so practically speaking, your solution is probably better (though with the above-mentioned caveats).

A similar problem occurs with trying to imitate PHP's extract() and compact(). We don't have a way in JavaScript (unless we exclusively work with globals) to say use the arguments object to obtain or set the local variables of the caller (we can only get access to those variables explicitly passed in as arguments, and only by reference if they are objects or arrays).

I think these may well be the biggest challenges for php.js trying to follow the PHP API.

Gravatar
Brett Zamir
29 Dec '09 Permalink

q   @cynosure: Looks like someone else here tried something similar: http://phpjs.org/functions/array_pop:329#comment_354 .

As far as a reference to an array, whatever value you pass in to a function, if it is an array or object, its elements can be acted on by reference and in fact only by reference unless you manually make a copy (though you cannot replace the whole object with something else, or that does make a copy). So, we could adapt your function to work by reference (though still breaking the PHP API which only uses one argument):

1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
function unset(array,index) {
    if (typeof array === 'object' && typeof array.length !== 'undefined') {
        array.splice(index, 1); // Using the delete operator will replace the old value 
        // with "undefined" in its old slot, but we also want to remove the slot itself, 
        // so with arrays (in IE too), we can safely use splice().    }
    else { // Objects
        delete array[index]; // For object properties, this works pretty well, except potentially in IE where 
        // the property will thankfully no longer be iterated, but it has the annoying feature (for 
        // the sake of our using objects to imitate PHP associative arrays) that if you later try to         // add back a value with the same property name, it will put your new value in the old 
        // iteration position.  So IE does not truly delete the property, though it may appear that way.
        // All other popular browser implementation seem to truly delete the property (and iterate 
        // in order), at least if it is not an inherited property, but the latest ES spec wasn't able 
        // to persuade IE to change this behavior    }
}


See the 2nd comment above for the potential problems with this though. Basically in IE, simple objects as associative arrays just won't work perfectly. It is very disappointing. You can get around this by creating an object which wraps your data, but that can get quite ugly. Otherwise, you just have to keep your keys in one array and values in another array.

This is not to speak of our other challenge here of trying to work with only one argument in unset(). JavaScript does not allow us to get the container object or array if we only know the property. Our experimental version of unset() (at http://github.com/kvz/phpjs/blob/master/_experimental/var/unset.js ), allows us to pass in a single argument, but it is a (necessarily) very bad solution as it relies on eval(), and only works on globals passed in as strings. That's a huge compromise just to work with a single argument, so practically speaking, your solution is probably better (though with the above-mentioned caveats).

A similar problem occurs with trying to imitate PHP's extract() and compact(). We don't have a way in JavaScript (unless we exclusively work with globals) to say use the arguments object to obtain or set the local variables of the caller (we can only get access to those variables explicitly passed in as arguments, and only by reference if they are objects or arrays).

I think these may well be the biggest challenges for php.js trying to follow the PHP API.

Gravatar
cynosure
28 Dec '09 Permalink

q   Hi!

In JS can you give a reference to an array in a function call? I need an unset() like function what can cut off an element from an array with a given index ( like unset(foo['bar']; )

My workaround is this:

1
2
3
4
56
7
8
9
1011
function unset(array,index)
{
    var newarr = new Array();
 
    for(var i in array)    {
        if(i != index) newarr[i] = array[i];
    }
 
    return newarr;}


I know this is not the exact way how php's unset works, 'cos it gives only a reference to the array, and handles single variables as well as multiple variables too, but I think this can be usefull for those JS beginners like me, who wants to unset an element from an array. The delete method is buggy for me, or I don't understand how it works well.

Thanks!

Gravatar
Brett Zamir
23 Dec '09 Permalink

q  I misspoke in saying that the case in the switch is superfluous. It will indeed convert "\\0" to "\u0000" as in PHP. In any case, as I mentioned, you should add an extra '0' to the sequence (and don't add a backslash).

Gravatar
Brett Zamir
23 Dec '09 Permalink

q  @Brant: Sorry, the case in the switch is not superfluous as it will turn "\\0" into "\u0000" (as does PHP in double or single quotes). In any case, the rest of what I said still applies: don't add a backslash to "\u", just add an extra 0 at the end.

Gravatar
Brett Zamir
23 Dec '09 Permalink

q  @Brant: Thanks for letting us know. Fixed in Git. It really should be '\u0000' (was missing a zero), but it won't really make a difference either way because JavaScript already treats "\0" as "\u0000". So that case in the switch is superfluous (though I've kept it just to reflect what PHP does). FYI, "\u" is used to introduce a four-hexadecimal digit sequence in place of a Unicode character--esp. useful if you have to use non-printable characters or non-ASCII characters.

Gravatar
Brant Messenger
22 Dec '09 Permalink

q  IE7 Issue. Search for '\u000' and replace with '\\u000'.

Gravatar
Brant Messenger
22 Dec '09 Permalink

q   In a custom "wscs.namespaced.min.js" package IE7 found an error.

1
return false;},stripslashes:function(str){return(str+'').replace(/\\(.?)/g,function(s,n1){switch(n1){case'\\':return'\\';case'0':return'\u000';case'':return'';default:return n1;}});},stristr:function(haystack,needle,bool){var pos=0;haystack+='';pos=haystack.toLowerCase().indexOf((needle+'').toLowerCase());if(pos==-1){return false;}else{if(bool){return haystack.substr(0,pos);}else{return haystack.slice(pos);}}},strlen:function(string){var str=string+'';var i=0,chr='',lgth=0;var getWholeChar=function(str,i){var code=str.charCodeAt(i);var next='',prev='';if(0xD800<=code&&code<=0xDBFF){if(str.length<=(i+1)){throw'High surrogate without following low surrogate';}


Resolution:
1
return false;},stripslashes:function(str){return(str+'').replace(/\\(.?)/g,function(s,n1){switch(n1){case'\\':return'\\';case'0':return'\\u000';case'':return'';default:return n1;}});},stristr:function(haystack,needle,bool){var pos=0;haystack+='';pos=haystack.toLowerCase().indexOf((needle+'').toLowerCase());if(pos==-1){return false;}else{if(bool){return haystack.substr(0,pos);}else{return haystack.slice(pos);}}},strlen:function(string){var str=string+'';var i=0,chr='',lgth=0;var getWholeChar=function(str,i){var code=str.charCodeAt(i);var next='',prev='';if(0xD800<=code&&code<=0xDBFF){if(str.length<=(i+1)){throw'High surrogate without following low surrogate';}


Notice the difference '\u000' -> '\\u000'

Gravatar
Kevin van Zonneveld
14 Dec '09 Permalink

q  @ cynosure: Yip! Thanks for thinking of us though ; )

Gravatar
cynosure
3 Dec '09 Permalink

q  Sorry, I didn't saw that you found it already ;)

Gravatar
cynosure
3 Dec '09 Permalink

q  Hey Kevin, there are some md5() functions for JS around the web, for example this:

http://www.webtoolkit.info/javascript-md5.html

It's fast, I use it in a CRAM (challenge-response authentication) API.

Gravatar
Kevin van Zonneveld
29 Nov '09 Permalink

q  Thanks Danny, I've added a favicon : )

Gravatar
Nizam
25 Nov '09 Permalink

q   Hi Brett,

I really found this function very useful. If you don't have it, please consider this. thank you.

http://www.finefrog.com/2009/01/31/convert-a-mysql-date-string-into-javascript-date-object/

1
2
3
4
56
7
8
9
1011
12
13
14
15
function parse_date(datetime /* YYYY-MM-DD HH:mm:ss */)
{  
        var date = new Date();  
        var parts = String(datetime).split(/[- :]/);  
         date.setFullYear(parts[0]);  
        date.setMonth(parts[1] - 1);  
        date.setDate(parts[2]);  
        date.setHours(parts[3]);  
        date.setMinutes(parts[4]);          date.setSeconds(parts[5]);  
        date.setMilliseconds(0);  
 
        return date;  
}

Gravatar
Danny Wilkerson
23 Nov '09 Permalink

q  the website icon is missing "favicon.ico"

Gravatar
Brett Zamir
26 Oct '09 Permalink

q  @peta: Besides what Michael and Kevin said, if you can find the time to help us in borrowing those features from other frameworks that you speak of--without sacrificing the full PHP API that we've attempted to follow (in some cases, we have had to take a performance hit in some functions in order to support all of the potential PHP arguments)--then we're all for it. But as stated by Michael, we are, for better or worse, committed to following the PHP API (except in cases where we can use our own "ini" to configure function behavior)...

Gravatar
Kevin van Zonneveld
25 Oct '09 Permalink

q  @ Michael White: Thanks for chiming in Michael!

I would like to add that we're not in the business of porting language features. We're in the business of porting functions. Although JavaScript seriously kicks ass as a language, there's just no easy way to do higher level stuff like:

md5(), strip_tags(), strtotime(), number_format(), wordwrap()

That's were we come in. Please take a function you need (I'm sure the day will come you'll find a use for us if you're doing PHP & JS professionally) and be on your way.

At least that's how I look at it.

Gravatar
Michael White
20 Oct '09 Permalink

q  @peta I believe you may be missing the entire point of PHPJS. There are many PHP developers out there who feel much more "at home" with the PHP language than they do with JavaScript. While there are many other frameworks out there, a developer who's primary language is PHP may not have a chance to really learn one or more of those frameworks, especially on a project with a tight timeline. PHPJS is *not* meant to be a replacement for something like jQuery or Prototype but rather an additional asset. Frameworks like jQuery and Prototype are designed for manipulating the DOM, sending and receiving data, and other common client-side tasks. PHPJS used alongside one of the other frameworks would provide easier data manipulation functions at the developers fingertips rather. I'm not exactly a JS novice but I still find PHP's functions for string manipulation to be much more user friendly than JavaScript's - not to mention that even for the unfriendly stuff, the www.php.net documentation outshines any single resource for JavaScript documentation that I've ever come across.

Is there some way we can make it more clear that the purpose of PHPJS is not to replace frameworks like jQuery and Prototype but rather to assist people who are already familiar with PHP and need to use JavaScript for whatever reason.

Gravatar
peta
19 Oct '09 Permalink

q  Sorry, but where on earth are reasonable reasons to mimic ugly language constructs like those of PHP in JS? Most real-life functionalities being used by an average js developer are already implemented more cleverly and performant by one of the JS Frameworks being out there. Frankly, the idea behind PHPJS sounds nice, but a closer look at the sources and the performance of typical operations offered by PHPJS (tested most array, string and typechecking functionalities) sobers up very quickly.

Instead of continuing to follow a half-baked concept, I'd look to where langauge constructs of PHP might complement exisitng frameworks in a smart way, and implement these for one/more existing frameworks.

.peta

Gravatar
cltc
18 Oct '09 Permalink

q  Thanks!You saved my life...

Gravatar
http://www.my-picz.co.cc
15 Oct '09 Permalink

q  I'm trying to use the "array_walk_rucursive"-function,
but really don't know, how to make it work on my array.
Couldn't you add a sample function (other than "void()"),
to explain the idea of that function more understandable?

Gravatar
Gerald
12 Oct '09 Permalink

q  Thank you! I wasted hours trying to find js equivalents for php functions then trying to create my own equivalents. I'm glad I found you! You saved me hours of more wasted time! :)

Gravatar
Website Design Egypt
10 Oct '09 Permalink

q  I find it smart and clever idea. I love it. I am going to give a try and spend extra time then post again.

Thanks.

Gravatar
Kevin van Zonneveld
8 Oct '09 Permalink

q  @ Jeff & The JavaScript BUG: Yeah didn't quite get that sorry ; )

Gravatar
Kevin van Zonneveld
8 Oct '09 Permalink

q  @ Roland Hentschel: Our examples are also used for unit testing. Hence the strangeness.
Please refer to the official PHP documentation for more details on how to operate these functions.

Gravatar
Roland Hentschel
2 Oct '09 Permalink

q  Hi!

I'm trying to use the "array_walk_rucursive"-function,
but really don't know, how to make it work on my array.
Couldn't you add a sample function (other than "void()"),
to explain the idea of that function more understandable?

thanx ( -: roland :- )

Gravatar
Brett Zamir
22 Sep '09 Permalink

q  @The JavaScript BUG: Maybe Kevin knows what you mean, but I can't figure it out. Care to clarify?

@Jeff: Much as we'd like to sometimes, we're not able to read minds here. :) What are you talking about? Plenty of people are using the functions here... What problems are you having exactly?

Gravatar
Jeff
21 Sep '09 Permalink

q  None of theses functions could be used!

Gravatar
The JavaScript BUG
17 Sep '09 Permalink

q  the right div sponsor redirect from contain into div from other url...

Gravatar
Kevin van Zonneveld
6 Sep '09 Permalink

q  @ Shawn Houser: Wow! You are the first official PHP.JS donor Shawn! How very kind & generous of you!

I'll make sure that:
- We pull in the RSS feed from http://pledgie.com/campaigns/5962 so that your name gets a nice place somewhere on this site.
- The donations are used to cover expenses
- Should we raise more - The donations are divided amongst code contributors in a fair & transparent way.

That last point has to be worked out more, But probably only the "Gold" authors though so that:
- It motivates people to get/keep their Gold status
- It doesn't become an administrative hell - which we don't want to lose too much time on.

But this stuff ^^ is mostly to engage a discussion with every other PHP.JS voice. To you Shawn I would like say: Thank you so much! : )

Gravatar
Shawn Houser
6 Sep '09 Permalink

q  Guys, I just wanted to say thanks for all your hard work. This project is AWESOME!

Gravatar
Kevin van Zonneveld
5 Sep '09 Permalink

q  @ Philip Peterson: About the global variables; there's some discussion about it here
http://phpjs.org/functions/import_request_variables:431#comment_92699

Gravatar
Kevin van Zonneveld
4 Sep '09 Permalink

q   @ Philip Peterson: After receiving no more replies on the dev [ at ] phpjs [d.o.t.] org mail account & also not receiving the form you intended to send to me I figured you had other occupations. If you'd like to join in again that's fine by me; it's been a coming & going of core devs anyway and that's fine.
Brett & I do most things by mailing directly & answering comments now.
Feel free to help out with that and I can reinstate you & cc you in our mailings (for all I know, the dev@ account stopped working, we'll just use our own addresses for that).

Gravatar
alok
4 Sep '09 Permalink

q  hi testing

Gravatar
viconcursos
29 Aug '09 Permalink

q  parabens. muito bom isso..!

Gravatar
Philip Peterson
15 Aug '09 Permalink

q   Hmm... maybe we should add the $_GET and $_POST[if possible] -type superglobals to phpjs, since they're pretty core to PHP itself?

By the way, why did I become a ex-core developer? :( I stopped receiving/getting replies to my dev emails so I figured the project was at a standstill.. I'd be happy to join in again, though, if possible :)

Gravatar
Kevin van Zonneveld
4 Aug '09 Permalink

q  @ Yusuf & Brett Zamir: The wiki is set up. Compiler: Unfortunately I wasn't able to reproduce the issue. I just compiled this one:
http://phpjs.org/packages/view/1330/name:56d24eeb06cd846085333b87901bf7b3

Is it much different from the configuration you were trying to build?

Gravatar
Brett Zamir
2 Aug '09 Permalink

q  I really wish this code highlighter didn't have this issue with being unable to copy-paste without getting numbers, but if you hover your mouse in the top right of the code box, you'll see an entry which you can click to get a plain text view of the code.

As far as the compiler, hopefully Kevin can see what might be going on with it...

Gravatar
Yusuf
1 Aug '09 Permalink

q  the other one is, when I was browsing functions one by one, I couldn't copy them properly. is it possible to use a javascript function to copy them with a single button? BTW, the compiler didn't work. I selected my functions, named the library and then clicked on the compile button, but only an empty page appeared when the page loaded. Are there others experiencing something of this kind, or am I the only one?

Gravatar
Brett Zamir
29 Jul '09 Permalink

q  @Yusuf: You said you had two wishes--was there another? As far as the one you mentioned, while the PHP documentation should itself provide good documentation and examples, Kevin has now set up a wiki (at http://phpjs.org/wiki ), so feel free to contribute any examples there.
@Kevin: Maybe we could use the wiki to allow people to more easily report how their projects are using php.js?

Gravatar
Brett Zamir
29 Jul '09 Permalink

q  @kam66be: the issue you reported had earlier been fixed, but is just now being made public... Thanks for the report!

Gravatar
Yusuf
28 Jul '09 Permalink

q  hi everyone, first of all, many many thanks to those launching and maintaning such an useful, as well as exciting, project. its already superb, but I have two additional wishes, thinking they will increase its usability. I suggest a few real examples with this library be coded and published.

Download

Download

There is a wide variety of packages if the default doesn't suit you.
You can also compile your own package to avoid any overhead.

Support us

spread the word:


Use any PHP function in JavaScript


These kind folks have already donated: Anonymous and Shawn Houser.
<your name here>

Click here to lend your support to: phpjs and make a donation at www.pledgie.com !

RSS

Tweets

Comments

Who uses php.js

If you use php.js, let us know and get linked.

Progress

php.js is complete for 83.7%

php.js on

Discuss php.js' future at Google Groups
Help improve php.js on github



Powered by php.js
Stats