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 7854291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:01:00+00:00 2026-06-02T20:01:00+00:00

Im trying to test a validation using an if statement. if (($red == 1)

  • 0

Im trying to test a validation using an if statement.

if (($red == "1") && ($blue = "1") ) { $green = "hello"; }

Before this statement runs $blue = 0.

After i run this… $blue changes to 1.

Any ideas why?

  • 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-02T20:01:01+00:00Added an answer on June 2, 2026 at 8:01 pm

    You are using = in place of ==:

    if (($red == "1") && ($blue = "1") ) { $green = "hello"; }
                               ^^^
    

    As a result (assuming the left side of && returns true) $blue gets assigned "1".

    It’s one of the most common programming mistakes!! As a way to prevent it from happening programmers put the constant on the left hand side of the the == as:

    1 == $blue
    

    so that if by mistake you end up writing = in place of == :

    1 = $blue
    

    you get a syntax error as you cannot assign to a constant.

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

Sidebar

Related Questions

Im trying to test my successfully creates a new user after login (using authlogic).
I am trying to test Xsd Validation using Saxon. When I get to the
I am trying to using this RegEx for color validation. colorPattern = /\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/ but
just trying to test for equality in this piece of code, but getting a
I'm trying to test using QTP a web app that is using ajax4jsf to
I am trying to set up input validation using regular expressions, but I keep
I am trying to test a model's attributes for formatting with this: # myapp/test/unit/comment_test.rb
I'm trying to implement IP address validation on my page. I have a test
I'm trying to use httplib's HTTPSConnection for client validation, using a PKCS #12 certificate.
I've been trying to build a pepXML to mzIdentML converter and using this validator

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.