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 to make this work??

Error to compare the two variables together.

index.php
<?php
$a = 5;
$isBoolean = true;
$isIdentical = '5';
$isIdentical ($a == $isIdentical);
//Place your code below this comment
?>

1 Answer

A few things here:

  1. On line 5 in your excerpt, you are missing an "=" between $isIdentical and the opening parentheses "(".
  2. The instructions for the challenge tell you to: "Compare the variable $a as equal and of the same type as the string "5" and assign the results to $isIdentical." So, we aren't just seeing if the values match - we're seeing if the TYPE of value matches (e.g. string, integer, boolean, etc).

So, we should have code that looks like this:

<?php
$a = 5;
//Place your code below this comment
$isBoolean = true;
$isIdentical = ($a === "5"); // Note how we use three equals ("===")
?>

Do you see the difference between $a (which has a value of 5) and "5"? There are no quotes around the 5 in $a, because it's an integer. The quotes around "5" tell PHP to handle it like a string. A double equal sign (==) compares the value, a triple equal sign (===) compares the TYPE of value.

Hope that helps - you were on the right track, just missing a couple equal signs :)

Thank you :)