1) CODE TITLE: Javascript serializer
2) AUTHOR NAME/NOTES: Shachi Bista
3) DESCRIPTION: Serializes any string like the traditional PHP serialize function
4) URL TO CODE:
or, ATTACHED BELOW (see #3 in guidelines below):
1) CODE TITLE: Javascript serializer
2) AUTHOR NAME/NOTES: Shachi Bista
3) DESCRIPTION: Serializes any string like the traditional PHP serialize function
4) URL TO CODE:
or, ATTACHED BELOW (see #3 in guidelines below):
I'm not quite sure I understand... What exactly does it do?
- Mike
You would if you used the php serialize() function. Anyways it converts any plain text like this:
to:Code:test array(1,2,"b");
If you still don't get it then I suggest you to download the zip and check the html file. Even PHP sessions are in these formats.Code:s:4:"test" a:3{i:0;i:1;i:1;i:2;i:3;i:"b"}
Hope it helps.
Under SpiderMonkey:Changing this, it doesn't produce the same output as PHP serialize(). Compare:Code:jserialize.js:10: SyntaxError: final is a reserved identifier: jserialize.js:10: final = "a:"+item.length+":{"; jserialize.js:10: ................^Code:twey@peordh ~/Documents/ddstuff $ js -f jserialize.js -f - js> var a = []; js> a.push(a); 1 js> serialize(a); a:1:{i:0;a:1:{i:0;a:;}}Code:twey@peordh ~/Documents/ddstuff $ php <?php $a = array(); array_push($a, $a); print serialize($a); ?> a:1:{i:0;a:0:{}}
Last edited by Twey; 01-07-2007 at 04:34 PM.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Twey: Haven't tested it in all browsers. I never knew that even final was a reserved word. Too bad. Do you think changing that varname will fix the error?
It does. However, the difference in output remains.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Sorry, I modified my above post, apparently after you read it.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Umm yeah... Well. I have a question, what does the "final" keyword signify?
- Mike
mburt: I just have no idea.
Twey: I've got to fix that too, that goes into my TODO list, Thank you for pointing that out Twey. If I am lucky enough I'll certainly fix it.
There still are a lot of bugs that needs to be fixed. This is just an experimental script I created for AJAX to transfer and convert js arrays so that PHP can interpret them.
Bookmarks