Created
February 23, 2011 19:53
-
-
Save sbisbee/841032 to your computer and use it in GitHub Desktop.
A dirty piece of duct tape that converts a class into JSON.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
/* | |
* php2json | |
* by Sam Bisbee <[email protected]> | |
* on 2011-02-23 | |
* | |
* Takes in a class file, instantiates it, and then spits out its JSON. | |
* | |
* Example Usage: ./php2json.php UserVO.php | |
*/ | |
$file = $argv[1]; | |
require($file); | |
$class = substr($file, 0, strpos($file, '.php')); | |
echo json_encode(new $class)."\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment