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 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,704 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,704 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,704 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. : )