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 trialMartin Batista
4,606 PointsGetting 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; ?>
3 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey 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.
Jason Anders
Treehouse Moderator 145,860 PointsAnd 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
Courses Plus Student 4,370 PointsHere 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
4,606 PointsHere is the snapshot of my code: https://w.trhou.se/lyjh9oq8f4
thank you in advance for the help. : )
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsHey 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.