Yesterday an ex colleague tweeted something that captured my attention:

So I started thinking to a Twitter-powered code golfing competition. Looking for other examples you can see these:

This is Twittee: a dependency injection container in a tweet.

This is Twitto: a web framework!

And this is a microframework was create on the occasion of this “competition”. It’s called μ and you can find its documentation here.

These three are really nice examples of PHP code in a tweet. Of course you can’t use these two snippets in production, but you can see that a short script isn’t always an useless script or something prosy.

I realized two examples and I would be glad to see your tweets! :)

This is a function used to bypass the array_intersect note “Note: Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same.”

Using this you can check if a request is made using AJAX or is a simple web-client request.

I think this could be a nice game (and a personal test) for each PHP developer.

Game rules

  1. The tweet have to be a well-formed PHP code. You can check the right syntax using php -l tweet.php as described here:
  2. A code is taggable only using things like echo "#php"; or return "#error"; but still keeping your tweet a well-formed PHP code
  3. Open (<? and <?php) and close (?>) tags are not recommended

If you want suggest a ranking algorithm/formula, new rules or suggest methods to write the code, comment down here. For example you can evaluate comments, or the usage of some methods and classes, or evaluate more retweets than number of users that favorites your tweet, more the length or the utility, etc…

I would be glad to see your tweets, so comment here linking your tweets! :)

PS: to embed a tweet in a comment like I did down here, simply put the URL of your tweet in a line

Discussion on Hacker News