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.
very frustrated, not sure what I'm doing wrong? <?php $name ="Mike"?> <?php echo = "Mike"?>
PHP basics part 2, is asking to echo mikes name to the screen?
<?php $name ="Mike"?> <?php echo = "Mike"?>
Patrizia Lutz1,449 Points
You can't assign a value to echo, which is a PHP function that outputs a string (or multiple strings).
You should declare the variable
$name and assign the value "Mike". Then use
echo to print it out.
<?php $name = "Mike"; ?> <?php echo $name; ?>
<?php $name = "Mike"; echo $name; ?>
You can also concatenate strings and variables like so:
<?php echo 'Hi, my name is ' . $name . '.'; ?> //=> Hi, my name is Mike.
Jeff Lemay14,266 Points
KEEP EVERYTHING IN A SINGLE PHP BLOCK! This question comes up often. There should really be an instruction added to the code challenge.
But you also have some other issues...
- When you combine the two statements into a single php block, you'll need to close each with a semi-colon (well, technically, you only need to close the first one where you set the name variable)
- You are not echoing the variable properly. You tried echoing just a string, but you don't use an equal sign for echoing variables/strings.
<?php $name = "Mike"; echo $Mike; ?>
You almost had it. You created the variable some instead of typing "mike" every time you're able to just call on the variable.
<?php $name ="Mike"; echo $name; ?>
If you look at all the answers they're basically the same thing. I think it may be how you entered your answer.