Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:19:41+00:00 2026-06-08T04:19:41+00:00

Can’t get the point of === and !== with primitive types: $a === $b

  • 0

Can’t get the point of === and !== with primitive types:

$a === $b TRUE if $a is equal to $b, and they are of the same type.
$a !== $b TRUE if $a is not equal to $b, or they are not of the same type.

The assuming that $request->getMethod() returns GET or POST (as string) and that $form->isValid() returns a boolean true or false, the following code:

if('POST' === $request->getMethod() || (false === $form->isValid())) :
endif;

Does make any sense in respect of this shorter one:

if('POST' == $request->getMethod() || !$form->isValid()) :
endif;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:19:42+00:00Added an answer on June 8, 2026 at 4:19 am

    You have truty and falsy values in PHP. For instance, 0, '', array() are falsy values. If you use == it will match those values with the truty/falsy values:

    var_dump(true == 'hello'); // true because a not empty string is a truty value
    var_dump(false == 0); // true
    

    === will match not only the value but the type also:

    var_dump(true === 'hello'); // false, true is a boolean and 'hello' a string
    var_dump(false === 0); // false, false is a boolean and 0 is a string
    

    This will become a problem when a function can return 0 or false, strpos for example.


    There are also other factors with the ==. It will type cast values to a int if you compare 2 different types:

    var_dump("123abc" == 123); // true, because '123abc' becomes `123`
    

    This will be problematic if you compare a password: http://phpsadness.com/sad/47

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody point me to a resource that explains how to go about having
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can anybody help me? What should be the datatype for this type -07:00:00 of
Can we change the color of the divider? Apple documentations says, that we can
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Can somebody point me a good strategy for security crosscutting concern without AOP for
Can anyone help me with an excel formula that groups related rows and creates
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Can i get the source code for a WAMP stack installer somewhere? Any help

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.