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

How actually doing the identical comparison? Should be triple === ?

I got the question which is I already set the variable boolean two as a string "5", then compare with the variable $a which is number 5, which should return as false but it reply with task 1 is not passing? Have no idea what is going on. Thanks for help in advanced.

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

2 Answers

Muhammad Ehsan Hanif
Muhammad Ehsan Hanif
8,236 Points

In challenge 2 you have to compare the $a with string 5 like this.

$booleanTwo = $a === '5';

Thank you so much, but i still wondering since i did declare the $booleanTwo as a string (5), then why dont just compare like what i did ($a === $booleanTwo)? Because $a is a number and $booleanTwo is a String "5", it should be correct? Thank you in advanced.

Muhammad Ehsan Hanif
Muhammad Ehsan Hanif
8,236 Points

Yea, you can compare it like that too. But that won't let you pass the challenge as it is asking "Set $booleanTwo equal to the result of comparing the variable $a as IDENTICAL to the string "5"

Okay, thank you for explanation. I am fully understand now, again thank you for help me to resolve the problem i met.