Sachin
Sachin

Reputation: 217

what is the mistake in this logic for php comparison?

when I give

 <? echo $submissiontype ?>

I am getting the output as

  PRIORITY 

but for the below code, i am expecting the output as

 selected

but I can't get it,

<? if($submissiontype == 'PRIORITY') {echo 'selected';} ?>

what is the mistake in the above code ?

Upvotes: 0

Views: 42

Answers (2)

Tiago
Tiago

Reputation: 378

You can also use string compare, strcmp

if(!strcmp($submissiontype," PRIORITY")) {
echo "selected";
}

Upvotes: 0

SomeShinyObject
SomeShinyObject

Reputation: 7801

What if you trim $submissionType type first.

<? if(trim($submissiontype) == 'PRIORITY') {echo 'selected';} ?>

Often there are whitespaces that we don't account for.

Upvotes: 3

Related Questions