OO and hipster beards
Those annoying front-end programmers with their hipster beards and designer shoes are currently porting the company's main application. The new version will be better, more intuitive, more responsive, clearer to the user, offer a better user experience, comply to web standards, use cutting edge technology, reduce server load, is indefinitely scalable, at least @ Web 3.0 if not Web π, have lots of social media integration, a mobile version and (drumrolls.....) a Twitter feed.
Luckily you can let them play in their sandbox with their jQuery shovels and HTML 5 buckets in the comforting knowledge that you can just dump your well thought out business objects into json_encode()
to serve their XHR requests:
<?php header("Content-type: application/json"); echo json_encode(new Account(intval($_GET["account_id"]))); ?>
Or can't you?
p>A: Yes, that will keep'em busy for a while.
B: No, json_encode()
will casts its argument to a string, so invoking the __toString()
method of the Account class.
C: No, json_encode()
will not find the private and protected properties of the class, and all my classes expose their members through accessor methods.
D: Nice try: there is no such media type.
What's your answer?