T
T
Terion2012-01-09 12:39:20
PHP
Terion, 2012-01-09 12:39:20

Pass 0 in POST request

As you know (well, or not everyone knows, I don’t know), when trying to send the number 0 or a string consisting of zeros via POST to PHP, we will not receive anything on the server side, because anything == FALSE in post is truncated.
But this is very necessary!
Who solves this problem?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
M
Melkij, 2012-01-09
@Terion

Parse your host. Maybe you are using a framework that runs all the data through empty and removes, in his opinion, unnecessary.
PHP doesn't do that.

A
Arkady, 2012-01-09
@p0is0n

The first time I've heard. var_dump($_POST) what's going on?

F
falstaf, 2012-01-09
@falstaf

I'm sorry, of course, but nonsense.

A
Alexander Kouznetsov, 2012-01-09
@unconnected

don't use the stupid
if ($_POST["x"]) construct...
and you'll be happy if you
stepped on this rake yourself :)

I
IngvarrT, 2012-01-09
@IngvarrT

Using this method is not justified in your case, but, for general development:
file_get_contents( 'php://input' )
- will return the entire POST as it is. If the POST contains form data, then parse_str() can be used next.
But, in answer to your question, I join the opinion that the problem is not created by PHP, but by you. :)

V
Vitali Borovik, 2012-01-09
@WAYS

Everything is perfectly transmitted pix.am/uPe0/
In general, sometimes a method of cleaning data.

N
NeOn4eG, 2012-01-09
@NeOn4eG

if(0==false) - true.
if(0===false) - not true. No?

S
SharkyFLY, 2012-01-09
@SharkyFLY

type like (string)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question