Lee
Lee

Reputation: 3969

Integer constant doesn't equate with regular integer?

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

Answers (1)

Kalpesh
Kalpesh

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

Related Questions