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 (Retired) PHP Data & Structure PHP Variables

Martin Batista
Martin Batista
4,606 Points

Getting Notice: Undefined variable: name in /home/treehouse/workspace/index.php on line 23

I declared all my variables correctly: <?php> $name = "Mike"; $location = "Orlando FL"; $fullName = Mike The Frog; $name = $fullName; ?>

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hey Martin,

You will need to post a snapshot of your Workspace so we can help you troubleshoot. There is a 'camera' like icon in the top left corner of your Workspace. This takes a snapshot and provides you with a link. This URL can be posted in a comment on this post, if you like. Sometimes, you do need to open the link yourself and copy the URL from the address bar.

:dizzy:

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Martin,

Thank you for posting the snapshot. It looks like you have a minor typo/syntax error at the top of the file when you declare the variable $fullName (on line 4 in index.php) ... "Mike The Frog" needs to have quotation marks around it. Just add the quotation marks to surround the string and you should no longer have that error.

:dizzy:

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

And I just noticed, I don't think you need line 5. $name is supposed to hold the first name and $fullName holds, well, the full name. Line 5 is assigning the full name to the $name variable, overwriting the original declaration. Just double check that. :)

Florian Glembotzki
PLUS
Florian Glembotzki
Courses Plus Student 4,370 Points

Here is a working solution. For better definition of your problem a snapshot would help, like Jason posted before.

<?php
$name = "Mike";
echo $name;
?>
Martin Batista
Martin Batista
4,606 Points

Here is the snapshot of my code: https://w.trhou.se/lyjh9oq8f4

thank you in advance for the help. : )