Hi,
First, I tried searching for different variations of the title I've put for this question, both in StackOverflow and google. I couldn't find a solution.
I am fairly new to php. New enough to not know the difference between using eq
and ==
for string comparison!
I usually use ==
to compare strings in PHP. I am comfortable with it.
But I've seen code using eq
to compare strings. And I vaguely remember someone making an observation like 'oh! I used ==
to compare strings. I should have used eq
'
I just want to know whether using ==
is okay to do simple string comparisons? I am not talking about special cases, case-sensitive, substring or any fancy type of string comparison. Just checking whether apple
is the same as apple
.
Is ==
enough? or should I use eq
.
EDIT:
my mistake :( thanks a lot for clearing my 'not-well-researched' doubt! it must have been Perl. I got confused seeing the code embedded inside HTML and thought it was a different way of embedding PHP. sorry.