» PHP.JS Licensing
134 PHP equivalents
- » PHP.JS Licensing
- PHP.JS SVN
- PHP.JS Namespaced
- abs
- addslashes
- array_change_key_case
- array_chunk
- array_combine
- array_count_values
- array_diff
- array_diff_assoc
- array_diff_key
- array_fill
- array_flip
- array_keys
- array_key_exists
- array_map
- array_pad
- array_pop
- array_product
- array_push
- array_rand
- array_reduce
- array_reverse
- array_search
- array_shift
- array_sum
- array_unique
- array_unshift
- array_values
- base64_decode
- base64_encode
- basename
- bin2hex
- call_user_func_array
- checkdate
- chr
- compact
- count
- count_chars
- crc32
- date
- defined
- dirname
- echo
- empty
- end
- explode
- file
- file_get_contents
- floatval
- function_exists
- get_class
- get_included_files
- htmlentities
- html_entity_decode
- http_build_query
- implode
- include
- include_once
- intval
- in_array
- ip2long
- isset
- is_array
- is_null
- is_numeric
- is_object
- is_string
- join
- levenshtein
- long2ip
- ltrim
- md5
- md5_file
- mktime
- nl2br
- number_format
- ord
- parse_str
- preg_quote
- printf
- print_r
- rand
- range
- require
- require_once
- reset
- round
- rtrim
- serialize
- setcookie
- sha1
- sha1_file
- shuffle
- sizeof
- soundex
- split
- sprintf
- strcasecmp
- strchr
- strcmp
- stripos
- stripslashes
- strip_tags
- stristr
- strlen
- strnatcmp
- strpbrk
- strpos
- strrev
- strripos
- strrpos
- strstr
- strtolower
- strtoupper
- str_ireplace
- str_pad
- str_repeat
- str_replace
- str_rot13
- str_split
- substr
- substr_count
- trim
- ucfirst
- ucwords
- unserialize
- urldecode
- urlencode
- utf8_decode
- utf8_encode
- var_export
- wordwrap
PHP to Javascript Project: php.js
This article is part of the 'Porting PHP to Javascript' Project, which aims to decrease the gap between developing for PHP & Javascript.
A lot of people are familiar with PHP's functions, and though Javascript functions are often quite similar, some functions may be missing or addressed differently. The Javascript implementations should be as compliant with the PHP versions as possible, a good indication is that the PHP function manual could also apply to the Javascript version.
Porting crucial PHP functions to Javascript can be fun & useful. Currently some PHP functions have been added, but readers are encouraged to contribute and improve functions by adding comments. Eventually the goal is to save all the functions in one php.js file and make it publicly available for your coding pleasure.
If you choose to contribute, let me know how you want to be credited in the function's comments. You may also want to subscribe to RSS so you receive updates whenever new functions are posted.
Licensing
Since the project is really kicking off and we're almost at 100 ported functions, I thought it was probably time to think about licensing. So I did a little bit of research, and I think the MIT license might be what we're looking for.
In short, it permits reuse within proprietary software on the condition that the license is distributed with that software. It's also GPL-compatible, meaning that the GPL permits combination and redistribution with software that uses the MIT License.
The license
This is what I've come up with so far:
/*
* More info at: http://kevin.vanzonneveld.net/techblog/category/php2js
*
* php.js is copyright 2008 Kevin van Zonneveld.
*
* Portions copyright Ates Goral (http://magnetiq.com), Legaev Andrey,
* _argos, Jonas Raoni Soares Silva (http://www.jsfromhell.com),
* Webtoolkit.info (http://www.webtoolkit.info/), Carlos R. L. Rodrigues, Ash
* Searle (http://hexmen.com/blog/), Tyler Akins (http://rumkin.com), mdsjack
* (http://www.mdsjack.bo.it), Alexander Ermolaev
* (http://snippets.dzone.com/user/AlexanderErmolaev), Andrea Giammarchi
* (http://webreflection.blogspot.com), Bayron Guevara, Cord, David, Karol
* Kowalski, Leslie Hoare, Lincoln Ramsay, Mick@el, Nick Callen, Peter-Paul
* Koch (http://www.quirksmode.org/js/beat.html), Philippe Baumann, Steve
* Clay, booeyOH
*
* Licensed under the MIT (MIT-LICENSE.txt) license.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL KEVIN VAN ZONNEVELD BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
The "Portions copyright" section is updated autmatically as we update the source files.
Got ideas?
If any of you have different ideas about this license, please let me know, because this is an initial draft.
New to php.js ?
If you're new to php.js, checkout an example. We are not trying to port or emulate the entire language or control structures of PHP. We don't see the need because Javascript seems to have more elegant features in that category anyway.
However in our eyes, PHP does provide a large set of standard functions that make developing very easy, and some of them don't have good standard Javascript implementations, though they often would be great to have client-side.
So in this project by also providing the functions separately, we hope to keep people from inventing the wheel and give them a head start.
Like this article?
|
Then Dzone it! Or use another bookmark button below to show your support & help me spread the word. |
Hot StuffFlaming articles» Survive heavy traffic with you... | RelatedArticles like this one» Javascript equivalent for PHP'... |
tags: programming, javascript, php, phpjs
category: Programming - Javascript - PHP equivalents
read: 11,330 times






tagcloud
#16. is_array on 07 May 2008
#15. Shane on 06 May 2008
#14. Kevin on 28 April 2008
#13. Ozh on 28 April 2008
#12. Kevin on 21 April 2008
Thanks for sharing & taking an interest in our project!
#11. PhenX on 21 April 2008
http://www.ohloh.net/projects/php-js
We hope it will help :)
It would be nice to have a page completely dedicated to news and file downloads to be easier to find what we want. For now, it's hard to navigate into a blog for such a project
#10. Felix Geisendörfer on 06 April 2008
I'm currently working on a book called "JavaScript for PHP developers" and I see a lot of overlap between the work I'm doing and your efforts here.
So I'd love to have a little chat about how I may be able to help with your project. Contact me on felix@debuggable.com or any of the instant messagers listed here: debuggable.com/felix
... [more]
Thanks for the great work so far.
-- Felix
#9. Kevin on 20 March 2008
It should have auto-dependency resolving, optional packing or minifying, etc.
About your question, I'm in the midst of moving php.js to SVN, after that, the master file will have versioning as well. Currently only the separate function files have versions.
#8. Tim on 19 March 2008
I built a little script to make adding just parts of this great library available for download (packed with Dean Edwards packer). You can check it out at http://sitebytim.com/code/php_equivalents/ - FYI it's pretty rough at the moment so I hope to clean it up a little bit but it does the trick for what I need.
Just curious - if the individual files that have a single function (linked too from your testing page) are the same version as the functions included in the master php.js file?
#7. Kevin on 07 February 2008
#6. Jean-Lou Dupont on 06 February 2008
#5. Kevin on 04 February 2008
And though he already has made plans for www.phpjs.com to create a blog about working with symfony and dojo on web applications, I received a nice mail that he will still consider the transfer if he doesn't have enough time to kickstart that project.
We will be hearing from him next month.
#4. Kevin on 01 February 2008
Unfortunately my whois tells me there is no .js TLD.
I don't think PHP would appreciate a www.php.js domainname either ;)
#3. Kevin on 01 February 2008
Whereas MIT is cool with it if you incorporate & change php.js in your own app without ever exposing your improvements to the public.
But obviously, that does provide greater freedom.
#2. Karol Kowalski on 01 February 2008
#1. Legaev Andrey on 01 February 2008