What is the difference between 'eq' vs '==' in PHP?

At first I tried to find the various options for the title that I put for this question, both in StackOverflow and google. I could not find a solution.

I am new to php. Enough enough to not know the difference between use eqand ==to compare strings!

I usually use ==string comparison in PHP. It’s convenient for me.

But I saw code using eqstring comparison. And I vaguely remember someone noticing how “oh! I used ==to compare strings. I had to use eq'

I just want to know if use is ==for simple string comparisons? I'm not talking about special cases that are case sensitive, substring, or any style comparison of strings. Just check if appleit is the same as apple.

Is ==enough? or should i use eq.


EDIT:

my mistake :( Thank you very much for clearing my "not-well-researched" doubt! It might have been Perl. I was embarrassed to see the code embedded inside HTML and thought it was another way to embed PHP.

+3
source share
5 answers

: eq Perl string, == .

, PHP Perl, , .

+5

PHP eq. == ===.

=== .

== (, '' == 0 true).

Juggling PHP. , eq, version_compare().

+11

PHP eq operator. , perl, eq .

PHP (==) (===). (===) , . (==) , .

//this is true
'45' == 45

//this is false
'45' === 45

, == , , , , ===.

+2

== , , ... !

, , !

PHP, , ... : similar_text(), strcasecmp(), strcmp() .. , ereg(), eregi() !

+1

eq PHP ,

$a === $b

.

0
source

Source: https://habr.com/ru/post/1724920/


All Articles