Welcome Guest, Not a member yet? Register   Sign In
input class, post() bad behavior
#1

[eluser]Klaurus[/eluser]
Hello, it is normal the $this->input->post('item'); retrieves to me false when I had sent an empty array?
#2

[eluser]InsiteFX[/eluser]
Guess you did not read Phil's post on changing this behavior!

Change FALSE to NULL
#3

[eluser]Klaurus[/eluser]
No, I havent. Srry! Anyway, an empty array its not the same as null.
Suppose I want to do a foreach on the array, if the input class changes it to null then PHP will throw an error!
#4

[eluser]InsiteFX[/eluser]
You can read it here and add your own comments!

Change FALSE to NULL
#5

[eluser]Klaurus[/eluser]
I have readed Phil’s post, and what he wants to do its a good idea. BUT, its not the same that I am arguing.

Phil proposes that the methods should return NULL instead of FALSE when we dont send any data to the server.
Im saying that those methods should return an empty array when we send an empty array, because one expect to iterate over the array, or do some work on it.
And in this way we fall in the same problem as Phil has established about return FALSE.
#6

[eluser]Aken[/eluser]
NULL would still be the appropriate return. How is the application supposed to know that a POST item is an array, if no POST data has been sent? When accessing POST variables, there's no array syntax [] stuck on the names, so it has no way of discerning whether a non-existant variable is supposed to be an array or not.

If you send a single array-syntax item that's empty, it will return an array with a single empty string value, equivalent to:
Code:
array(0 => '')

If you send nothing, it will return FALSE (or NULL with the proposed changes).




Theme © iAndrew 2016 - Forum software by © MyBB