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 trialdevis
4,059 PointsDublicate code
<?php
if (isset ($_GET['name'])) {
$name = $_GET['name'];
}
/* as the same if statement is within the function itself now
the code snippet above is obsolete, isn' t it?
If it is redundant, please update the code example so that others don' t get confused.
Otherwise I appreciate any hint why the dublicate code is needed here.
Thank you.
*/
function greeting() {
if (isset ($_GET['name'])) {
$name = $_GET['name'];
echo "Hello, " . $name;
}
}
greeting();
?>
2 Answers
Jennifer Nordell
Treehouse TeacherHi there, devis ! I agree with you about the duplicate code. I'm not sure if it was included for emphasis, but I will bring it up with the education team. Thank you for bringing this to my attention!
Jaroslav Bílek
9,415 PointsWhy is isset doubled? To make it double safe?
devis
4,059 Pointsdevis
4,059 PointsHello Jennifer, thank you for the feedback
Tom de Visser
2,709 PointsTom de Visser
2,709 PointsHi Jennifer, it's still here! And in the quiz as well. Also confused me. Did you get an answer as to why it's added twice?