Contact
@Paul Smith: Thanks! Yes, I discovered that a while into my coding, but I guess I missed a few when I earlier tried to review this issue. FYI, although I was able to use "find-in-files" from Notepad++ to look for your example (it found the mode[i] in fopen and popen), if you see specific functions with problems, let me know the specific functions (I know, you probably thought the problem was systemic, but I think there really shouldn't be too many of these--I hope).
Hey, great code! But instead of accessing characters in a string via array index like
1 | mode[i] |
1 | mode.charAt(i) |
The reason being because
1 | mode[i] |
@Kevin: Thanks, that language looks like it will resolve the lawyer concerns. We appreciate your flexibility!
@ Chris Loer: I've updated the license page. Let me know if your lawyers run into any more problems with this. It is our intention that you can use php.js however you see fit. If they need some other text that follows this intention I'd be happy to place it.
I see your point about "or" also having ambiguity problems. I like Mozilla's wording. I think just about anything that clearly states "you can use either license" would make our lawyers happy (either within the license itself or in the "about the license" page). Although, of course, IANAL. If you or Kevin had a particular change in mind, I could run it by our legal department to see if it worked well for them: hopefully the benefit for the PHP .JS project would be that a change that satisfied our lawyers would also make the project more accessible to other people working within license-sensitive companies.
We haven't made any modifications so far, but if we do, we'd definitely like to be able to give them back. Our allergy to GPL is not so much the required opening of modifications as the "viral" part -- even though there are often "safe" ways for us to use GPL code, the cost of monitoring compliance from our end can be prohibitively high.
That's Kevin's call, but I'd think that "or" is more ambiguous--as if we're not sure how we want to license it. :) Mozilla tri-licenses (see http://www.mozilla.org/MPL/ ), and I like their wording there, "Core Mozilla project source code is licensed under a disjunctive tri-license giving you the choice of one of the three following sets of free software/open source licensing terms:"
And although it is under MIT, esp. if you encounter any bugs, we'd still like improvements returned if possible! :) Also makes it easier for you to have your improvements already included if we update.
And there is also even a PHP-way for us to customize functions too, by using our "global" php_js.ini variable (e.g., if you set ini_set('phpjs.objectsAsArrays', 0), it will force is_array() to treat objects as not being arrays (since we usually consider them as such to support associative arrays)). So if you have some custom functionality you'd like us to integrate, it is also possible for us to do it in a "PHP way".
My company is planning to use parts of PHP .JS in an upcoming release of our product. We appreciate all the work the community has put in for us to take advantage of!
Our legal department, however, is concerned by a possible ambiguity in the license at (http://phpjs.org/compiled/license.txt): where it says that the code is "Dual licensed under the MIT and GPL licenses," they worry that this could imply that the code is constrained by *both* the MIT and GPL licenses. Although I think it's clear that the intent is to allow people to use whichever license works best for them, a formal clarification would make the lawyers much more comfortable. The simplest change would be to just change "MIT and GPL" to "MIT or GPL". jQuery goes a bit further in spelling out their intent (http://docs.jquery.com/License).
Would it be possible to make a similar change to the posted PHP .JS license?
Thank you!
Hi there,
I just noticed this page: http://phpjs.org/functions/is_numeric:449
Where part of my function got integrated. Really gratefull, but if you go look at the page, you'll see the text partially disappear behind the column on the right.
I fear an
1 | overflow:scroll; |
Using Firefox 3.5.5 on Windows 7.
@Taras Bogach: Thanks much for alerting us to the issue. Rather than having to reimplement the third argument (and match your different naming of variables, etc.--btw, I recommend not using capital letters for regular variables as jslint suggests reserving them for constructors), I just added a call to krsort on 'from' in my own implementation which seems to have fixed the issue.
If you can better optimize what I have now in SVN (i.e., with the call to krsort), or provide a new and faster implementation with all arguments passing all test cases like mine is now, I can use yours instead. In any case, thanks for alerting us to the bug!
Sorry, now I have faster code:
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 | function(Input,Replace){ var Output="",InputSize=Input.length,StringSize=0; for(Code in Replace)if(Code.length>StringSize)StringSize=Code.length; for(var Offset=0; Offset<InputSize;){ var String="";DoReplace=false,ReplaceCode=null; for(var Size=StringSize; Size>0; Size--){ String=Input.substring(Offset,Offset+Size); if(Replace.hasOwnProperty(String)===true){ DoReplace=true; ReplaceCode=String; break; } } if(DoReplace==true){ Output+=Replace[ReplaceCode]; Offset+=ReplaceCode.length; }else{ Output+=Input.substring(Offset,Offset+1); Offset+=1; } } return Output; }; |
Bug in strtr()
PHP:
1 2 | echo strtr("aa",array("a"=>1,"aa"=>2)); //Will output: "2" |
JS:
1 2 | echo strtr("aa",array("a"=>1,"aa"=>2)); //Will output: "11" |
The right JS code for function (You may add the 3-d parameter):
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 | function(Input,Replace){ var Output="",InputSize=Input.length,StringSize=0; for(Code in Replace)if(Code.length>StringSize)StringSize=Code.length; for(var Offset=0; Offset<InputSize;){ var String="";DoReplace=false,ReplaceCode=null; for(var Size=1; Size<=StringSize; Size++){ String=Input.substring(Offset,Offset+Size); if(Replace.hasOwnProperty(String)===true){ DoReplace=true; ReplaceCode=String; } } if(DoReplace==true){ Output+=Replace[ReplaceCode]; Offset+=ReplaceCode.length; }else{ Output+=Input.substring(Offset,Offset+1); Offset+=1; } } return Output; } |
I use PHP.js to simply decode html_entities that I grab through twitters API.
1 | html_entity_decode(val.source) |
Hey Kevin!
My new hosted content management system is making use of PHPJS.
The URL is http://getsprink.com
@ Benjy: Ooh that was a really nasty bug, thanks a lot for bringing that to my attention. I fixed it up, tested it here:
http://phpjs.org/packages/view/917/name:e042ce5ee0716c3ba45da5519f70c744
And it seems to be working again. Happy compiling!
Hi,
Every time I try to get one of the namespaced packages, only the definition of the namespace is in the file, there are no functions (even if I try to make a custom package with only one function for example).
I think there's a bug with the namespacing... (occurs whether I choose minimify or not).
Thanks for your help,
Benjy
@nLight, first of all, what exactly is so terrible about novices being able to quickly and easily make a webpage do what they want it to do?
If you're worried that there code will soon become part of standard libraries, there are probably a whole host of more serious problems a novice will have in upgrading their sites (such as relying on the more-terrible-than-PHP JavaScript global problem) than thoughtlessly relying too much on the very few functions in PHP.JS which are little more than adapter wrappers (and given the performance lengths to which people will go to do things like get separation of concerns, why not accept a little cost for cross-language familiarity?--one brilliant Assembly language, etc. programmer I know even complains about mixing up the languages sometimes).
But if you actually look at the functions and consider how the PHP functions (and our implementations) only build on the functionality in JavaScript (we are using JavaScript after all!), you should notice that most of the many PHP functions we use offer extra arguments which would be useful enough to be recognized (in any other library which was not named after PHP) as justifying an added performance cost even if that's all they did (while in fact most PHP.JS functions go far above and beyond any single function or method in JavaScript).
One could also argue that PHP.JS will actually help people learn the cooler features of JavaScript since the code is very accessible to study. There is nothing preventing one from using JavaScript fully and also using very convenient PHP functions. And what really is the difference between using a function to do some useful manipulation if the name reuses a PHP name, and one which invents yet another library-specific utility name? Doesn't this reuse serve DRY?
I also commented on a similar complaint at http://phpjs.org/pages/home#comment_50909
Instead of learning such a great language as JavaScript is, monkey-coders will use this library to bring disgusting php functions in JS code.
cool work.. excellent and really helpfull.. I think this should be extended with jQuery or something like that..
keep it on , (2 thumbs up)
@ urtechnology: when we change functions it will be visible in the functions rrs feed here:
http://phpjs.org/functions/index.rss
i am very happy to use your code , is there any RSS Feed in your site ? , i like to update the latest update through the RSS Feed !
Any way it is a It's a great library!
Yes, Eugene, I believe there should be no problem with including our library in a GPL3-licensed project, since our license is more permissive. You should include our license terms with your project, indicating to which portions of the code it refers (i.e., the PHP.JS code before any changes you make), and there should be no problem with your doing so with GPL. The problem occurs if you try to go the other way around (from GPL to a more permissive license).
Of course, if you make changes to the PHP.JS functions, it'd be great for you to release those parts back to us as well under our same license terms (i.e., not only under GPL3) so we can use such improvements in our project, but that's your call since our license doesn't prohibit you from restricting the modified source if you wish (including if you want to make your changes to PHP.JS subject to the GPL as well). best wishes, Brett
Hi, I was just wondering... would a customized compile of php.js be allowed to be distributed in a GPL3-licensed project?
I would like to use it for my forum software: http://code.google.com/p/rambleforums/
Thank you :)
We use your code! We wanna get linked!
Not exactly in our site, but in some sites we develop.
Great work, thanks!
Excellent idea. I've put it directly under Development. But you can also review it at:
http://phpjs.org/compiled/license.txt
Hello Brian...Good point--The licensing is described at http://kevin.vanzonneveld.net/techblog/article/phpjs_licensing/ . It's an MIT-style license (copy-center like BSD/Apache). Kevin, do you want to put that info maybe under "Develop"?
Hey all,
Just a quick question about PHP.js licensing... your website lists the software as open source. Is there a specific license that you are using (GPL2, LGPL2, GPL3, BSD, Apache, etc)?
Thanks in advance!
Sincerely,
Brian
@ Jon Langevin: Thanks but I really like Cake, I just need to learn how to make it fast.. It's doable ;) Should be a lot faster now already.
Kevin, you're correct, your blog doesn't suffer from the same performance issue :-)
Good luck with Cake! If you need a lighter framework, I suggest CodeIgniter, as it's never seemed as hefty as Cake.
Cheers
@ Jon Langevin: I think the problem isn't my server. My blog is running on the same thing http://kevin.vanzonneveld.net and is servered swiftly (can you confirm that? maybe it's a transit issue)
I think I will have to blame CakePHP, and especially my little experience with it. I'm working on better caching so I hope things will be faster soon.
Thanks for your offer!
Hey guys, nice project you have here. One issue I've noticed, is that your website is either under extreme load, or on a poor server, as it responds very slowly, the transfer rate is very low, etc.
Do you guys need some help with hosting or do you need a mirror? Or is the performance issue I noticed fairly uncommon?
Cheers
-Jon



Brett Zamir
Jan 29th