MyBB Community Forums

Full Version: How to make $_POST['0'] to be an integer?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(2015-02-14, 06:30 AM)Omar G. Wrote: [ -> ]So $_POST['0'] is valid but $_POST[0] doesn't works? Weird.

I believe that is because the name attribute of a form element is a string and shouldn't start with a number. By using single quotes the 0 is treated as a string.
(2015-02-14, 01:48 PM)dragonexpert Wrote: [ -> ]
(2015-02-14, 06:30 AM)Omar G. Wrote: [ -> ]So $_POST['0'] is valid but $_POST[0] doesn't works? Weird.

I believe that is because the name attribute of a form element is a string and shouldn't start with a number.  By using single quotes the 0 is treated as a string.

The name attribute of input elements can start with a number or be just a number, why wouldn't that be allowed?

The reason why 0 as integer is not working is because $_POST/$_GET are arrays and that would mean you're trying to accesss the first element. But they're associative so nothing is accessed.
Pages: 1 2