Reputation: 3969
Quick question: Why does the below always compare as false, despite both showing 22 when printed? And no, the constant doesn't define the int with quotes.
<?php
...
if(count($_POST) != _NUM_TEAM_REG_FORM_FIELDS_)
$fields = $_POST;
else die(Core::FormatError("Incorrect number of form fields."));
?>
Thanks!
Upvotes: 0
Views: 438
Reputation: 5695
Why does the below always compare as false, despite both showing 22 when printed?
Beacause you have compared it falsely. (i.e. You have used != instead of ==)
Try below code instead,
if(count($_POST) == _NUM_TEAM_REG_FORM_FIELDS_)
$fields = $_POST;
else die(Core::FormatError("Incorrect number of form fields."));
Note, I have COMPARED them as EQUAL TO.
Upvotes: 3