Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Basics Daily Exercise Program True PHP

Barak TheProgrammer
Barak TheProgrammer
1,773 Points

cant pass this task, i dont really understand the meaning on every sy so i probably missed here somewhere

please help me with how to write what they're asking for

index.php
<?php
$a = 5;
//Place your code below this comment
$booleanOne = true;
$b = '5';
$booleanTwo = ($a == $b);

?>
Barak TheProgrammer
Barak TheProgrammer
1,773 Points

Create a new variable name $booleanTwo. Set $booleanTwo equal to the result of comparing the variable $a as IDENTICAL to the string "5".

This is the Task^^

2 Answers

-- --
-- --
12,382 Points

Hi there. :)

You need to compare the variable $a as identical (===) to the string "5" instead of equal (==), like so:

      $booleanTwo = ($a === $b);

And compare it to a string (not a variable) to pass the task, like so:

      $booleanTwo = ($a === "5");

You can remove variable $b from your code.

The difference between "==" (equal) and "===" (identical)

If you'd apply a var_dump on $booleanTwo, it would output bool(false). This is because variable $a is an integer, which is being compared to a string - in other words, the two entries are not IDENTICAL, because, even though the operands hold the same value, they are not from the same type (integer & string).

The integer and the string are EQUAL though (they're both 5 - the value is the same), so if you would remove one "=" (to make the comparison 'equal'), the var_dump would output bool(true). "==" does not check the type of the operands - only the value of the operands has to be the same for the comparison to be considered 'true'.

I hope you understand now. Good luck! ??

Michael Hallisey
Michael Hallisey
2,636 Points

You need 3 = signs. $booleanTwo = ($a === $b);