Created
April 23, 2012 16:27
-
-
Save philsturgeon/2472086 to your computer and use it in GitHub Desktop.
Dealing with CodeIgniter's incorrect defaults
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
/*/* | |
* CodeIgniter likes to return FALSE instead of NULL, which means | |
* that you need to check for FALSE before sending things of to | |
* the DB - amonsgt other issues - as well as the fact that FALSE | |
* is actually a value and not a valid "I dont know" response. | |
*/ | |
// NULL default in PHP 5.3 | |
$foo = $this->input->post('foo') ?: NULL; | |
// NULL default in PHP 5.2 | |
$foo = $this->input->post('foo') ? $this->input->post('foo') : NULL; | |
// NULL default proposal in CodeIgniter 3.0 | |
$foo = $this->input->post('foo'); | |
/* | |
* Seems trivial, but this is how pretty much everyone else in all of | |
* PHP land does it. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment