What does this double == do?

Posted on 2009-02-13
Last Modified: 2012-05-06
I'm editing some code written by someone else.

I trying to figure this statement out:

$tried2 = ($_POST['f_tried2'] == 'yes');

the data being posted (f_tried2) would either be 'yes' or nothing.

I understand that one = assigns a value.  And I have used double == to test equavelency in an 'if' statement.  But does this statement make the value 'yes' if the post has something in it or what?
Question by:St_Aug_Beach_Bum
    LVL 2

    Accepted Solution

    this code will asign boolean (true or false) to variable $tried2
    so if $_POST['f_tried2'] is equal to 'yes' then $tried2 will get value 1 else 0

    you can also write
    if($_POST['f_tried2']=='yes') $tried2=1; else $tried2=0;

    Author Closing Comment

    ah, thank you, that helps with the stuff I'm trying to add in, appreciate it.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now