Jump to content

!empty($_POST['v_order'])) treat v_order=0 as empty


Alexancho
 Share

Recommended Posts

I do usual verification:

if (isset($_POST['v_order']) && !empty($_POST['v_order'])) {} //Continue checkelse {die('Something wrong with the 'v_order'!); }

When v_order=0 the line "die('Something wrong with the 'v_order'!);" is executed.If i change 0 to any other number, everything work correctly.I can avoid this case, but i don't understand why it is happened. Isn't zero a number?

Link to comment
Share on other sites

0 is considered empty, according to the PHP manual. This is why it doesn't pass the check. Scrolling down in the link I've given, you'll find people who have implemented custom functions for correcting the... "issue" (but do remember that "it's not a bug. it's a feature").

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...