Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 3.0 Proposed Change: NULL v FALSE
#21

[eluser]Phil Sturgeon[/eluser]
[quote author="solepixel" date="1335278498"]I wish it could work more like PHP $_GET and $_POST. So foo is set in $_GET, then return NULL if the value is empty, but if it is not set, return false. If we have to options, why not utilize them both?[/quote]

That does not make any sense. If something is set then it should return whatever value is there, if something is not set then it should be NULL.

That is the principle that basically everything in PHP follows.

Using $_GET natively means you loose protection and get warnings thrown about "undefined index in array" instead of getting NULL returned.
#22

[eluser]solepixel[/eluser]
No, I think you misunderstood. You're right, if foo is set, it should return the value. I'm not saying resorting back to using native $_GET, however I would like the ability to do $var = $this->input->get('foo'); // be able to differentiate between url.com/?foo and url.com/?foo= (ex.1 foo === NULL, ex.2 foo === '')
#23

[eluser]Phil Sturgeon[/eluser]
Ok I'm glad we're not talking about native global variables, but I still don't know what you mean.

As I can see you have described exactly how it currently works, other than the NULL or FALSE difference which is what we are discussing. If an empty string is passed then an empty string will be returned, otherwise it will pass the default (which is currently FALSE but should be NULL).
#24

[eluser]solepixel[/eluser]
I guess what I'm getting at is, sorry i have sucked at communicating this.
Code:
$foo = $this->input->get('foo');
// url.com/?foo returns NULL
// url.com/?foo= returns '' (or whatever foo is set to)
// url.com/?bar returns FALSE

What I meant earlier is this is something we can do with native $_GET and it would be nice to be able to do it with the input library.
#25

[eluser]Phil Sturgeon[/eluser]
Why would // url.com/?foo and url.com/?bar return anything different?

You are confusing me quite a lot here.

I am not proposing any change to the logic of how anything works, I'm just saying the default should change. If you'd like to talk about any other functionality for the input library I would really appreciate you taking the suggestion to another thread, or an issue on the GitHub tracker.
#26

[eluser]solepixel[/eluser]
Because url.com/?foo is not the same as url.com/?bar when it comes to:
Code:
function get($foo){
   if(isset($_GET[$foo])){
      return $_GET[$foo]; // url.com/?foo=
   }
   return FALSE; // url.com/?bar
}
#27

[eluser]Paul Rose[/eluser]
+1 for this. Pretty big gripe with FALSE's everywhere! Seems the system as it is, is a bit mized already with NULL/FALSE here and there. NULL should be the standard.

Also: not sure how I didnt know about ?: operator in 5.3 - thats sweet!
#28

[eluser]Paul Rose[/eluser]
[quote author="solepixel" date="1335279790"]Because url.com/?foo is not the same as url.com/?bar when it comes to:
Code:
function get($foo){
   if(isset($_GET[$foo])){
      return $_GET[$foo]; // url.com/?foo=
   }
   return FALSE; // url.com/?bar
}
[/quote]

/?foo would be exactly the same as /?bar
/?foo= wouldntbe be the same as /?bar I imagine...
#29

[eluser]Phil Sturgeon[/eluser]
[quote author="solepixel" date="1335279790"]Because url.com/?foo is not the same as url.com/?bar when it comes to:
Code:
function get($foo){
   if(isset($_GET[$foo])){
      return $_GET[$foo]; // url.com/?foo=
   }
   return FALSE; // url.com/?bar
}
[/quote]

WHAT ARE YOU ON ABOUT?

Because url.com/?foo is not the same as url.com/?bar well. YES IT IS.

Because url.com/?foo= is not the same as url.com/?bar. Correct.

Please, stop talking about this.
#30

[eluser]solepixel[/eluser]
Sorry, I'm just referring to the ability to check if "foo" is set. The only reason I used "bar" was to show an example of "foo" not being set. Sorry about the confusion.




Theme © iAndrew 2016 - Forum software by © MyBB