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

Alice Ng
Alice Ng
1,560 Points

Not passing this test, please help

My code seems legit. but error msg saying cant find $booleanTwo somehow. Can someone please point out where am i wrong please.

index.php
<?php
$a = 5;
$booleanOne = true;
$booleanTwo = var_dump($a==="5");
?>
Jock Perkins
Jock Perkins
8,432 Points

You have used the triple equals, which looks not only for value but type as well.

You're setting $a = 5; - which is an integer, and then looking for $a === "5" - which is a string.

Try something like :

$a = 5; $booleanOne = true; $booleanTwo = var_dump($a===5);

or

$a = "5"; $booleanOne = true; $booleanTwo = var_dump($a==="5");

1 Answer

Robert Gouveia
PLUS
Robert Gouveia
Courses Plus Student 1,714 Points

@Jock Perkins, it does not matter if he is using "" or not, because of the === it will be a true or a false regardless of the "".

That is because the boolean is not working because there is an illegal bit of code.

Try this

<?php
$a = 5;
$booleanOne = true;
$booleanTwo = $a;

if(($a === "5") === true){
  echo 'true';
} else {
  echo 'false'; 
}

var_dump($booleanTwo);
?>

Let me explain it with comments what you did wrong.

//this is fine because you have assigned a integer to a variable
$a = 5;

// this is fine because you have assigned a true state to a variable
$booleanOne = true;

//this is wrong on 2 things:
//1. you can not assign a comparable state to a variable, you need an if statement for that
//2. you can not use a var_dump function to assign on a variable.
$booleanTwo = var_dump($a==="5");

Hope this helps