Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics (Retired) PHP Conditionals & Loops Conditionals Challenge

Andrew Lenti
seal-mask
.a{fill-rule:evenodd;}techdegree
Andrew Lenti
Front End Web Development Techdegree Student 7,193 Points

If statement using var_dump

Hello, I believe I am having some type of syntax error which unfortunately is blocking me from going forward with completing the PHP BAsics course. I am trying to write an if statement that confirms that the variable $name is equal to 'Mike'. I am stuck on the last step (3 of 3) where the instruction is to echo a statement 'Hi, I am Mike!' in the event that the statement is true. Please help.

index.php
<?php
$name = 'Mike';

if(var_dump( $name == 'Mike' )){
    echo 'Hi, I am Mike!';
} 

?>

If ($name=='Mike'){echo 'Hi, I am Mike!'};

1 Answer

Codin - Codesmite
Codin - Codesmite
8,600 Points
<?php
$name = 'Mike';

if($name === 'Mike' ){
    echo 'Hi, I am Mike!';
} 

?>

The question does not request the use of var_dump().

A correct use of var_dump would be for example:

<?php

$names = ['Mike', 'Andrew', 'Pete'];

var_dump($names);

?>

Which would output

array(3) { [0]=> string(4) "Mike" [1]=> string(6) "Andrew" [2]=> string(4) "Pete" }

var_dump() function displays structured information about one or more expressions that includes its type and value. It is an output function like echo.