Created
August 31, 2009 19:50
-
-
Save breck7/178666 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/* | |
easier way to deal with $_POST & $_GET etc: typecast it to an object. | |
$post = (object)$_POST; | |
benefits: | |
- quicker to type (30% faster to type $post->username than to type $_POST['username']) | |
- reduces chance of making syntax mistakes(you have to make sure to match 2 sets of tokens( ' and [ )in the former and 0 in the latter, reducing the likelihood of annoying syntax mistakes. | |
- easier to read? | |
downsides: | |
i have not researched the downsides, but they may include: | |
- efficiency (time spent typecasting and additional memory needed for object) | |
- security? (not sure if there would be any dangerous bugs here) | |
- clarity. I could see some people finding it easier to just use $_POST. | |
?? | |
*/ | |
$post = (object)$_POST; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment