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 trialAndrew Lenti
Front End Web Development Techdegree Student 7,193 PointsIf 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.
<?php
$name = 'Mike';
if(var_dump( $name == 'Mike' )){
echo 'Hi, I am Mike!';
}
?>
1 Answer
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.
Siphe Mak
933 PointsSiphe Mak
933 PointsIf ($name=='Mike'){echo 'Hi, I am Mike!'};