[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Difference between "=" and "=="

I am just making sure I understand this correctly. "=" is only to be used when assigning value, whereas "==" is used to check if something equals another thing? Is this correct?

0
stormist
Asked:
stormist
1 Solution
 
wildzeroCommented:
When you asigned something like
$a = 1; then

echo $a displays 1

however you use == in statements to compair

exmaple

If ($a == 1) {
  echo 'Statement is true';
} else {
  echo 'Statement is false';
}


So yes you are correct.
0
 
snoyes_jwCommented:
And just to throw a little more confusion in,
== means compare the values.  Variables will be cast to the relevant type.  (8 == '8') returns true.
=== means compare the values and types.  No casting occurs.  (8 === '8') returns false.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now