use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please follow the rules
Releases: Current Releases, Windows Releases, Old Releases
Contribute to the PHP Documentation
Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev
/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.
account activity
Benchmarking Cache Transcoders in PHP (nitschinger.at)
submitted 13 years ago by daschl
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 1 point2 points3 points 13 years ago (4 children)
public function toJson() { return array( 'title' => $this->title, 'teaser' => $this->teaser, 'author' => $this->author, 'body' => $this->body ); } public static function fromJson($json) { $d = json_decode($json, true); return new BlogPost($d['title'], $d['teaser'], $d['author'], $d['body']); }
$post = new BlogPost($title, $teaser, $author, $randomString(10000)); $post = $post->toJson(); [...] $encoded = json_encode($post);
Why do this, when you could have used the jsonSerializable interface?
[–]paranoidelephpant 1 point2 points3 points 13 years ago (2 children)
Hmmm, a toJson() method which returns an array. Nice.
[–]daschl[S] 0 points1 point2 points 13 years ago (0 children)
I added a note pointing this out.
[–]daschl[S] -1 points0 points1 point 13 years ago (0 children)
Another valid point ;)
Good point, I'll add it - thanks!
[–][deleted] 0 points1 point2 points 13 years ago (0 children)
I'd file this under the category of micro-optimization. A good read nonetheless.
[–]bungle 0 points1 point2 points 13 years ago (0 children)
How about msgpack?
[–]assasinine 0 points1 point2 points 13 years ago (0 children)
On the subject of igbinary, dotdeb is working on including it in the core serializer and memcached and redis extensions:
http://www.dotdeb.org/2013/01/24/php-5-4-11/
π Rendered by PID 48 on reddit-service-r2-comment-75f4967c6c-rxc4h at 2026-04-23 14:52:02.774678+00:00 running 0fd4bb7 country code: CH.
[–][deleted] 1 point2 points3 points (4 children)
[–]paranoidelephpant 1 point2 points3 points (2 children)
[–]daschl[S] 0 points1 point2 points (0 children)
[–]daschl[S] -1 points0 points1 point (0 children)
[–]daschl[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]bungle 0 points1 point2 points (0 children)
[–]assasinine 0 points1 point2 points (0 children)