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 trialDylan Ryan
4,855 PointsPHP Arrays and Control Structures - Broken Tasks
During the final step, when you are told to add a case for 'editor' and 'author' inside the switch: case, it is not registering 'editor'.
<?php
if (!isset($role)) {
$role = 'subscriber';
}
switch($role){
case 'admin': echo "As an admin, you can add, edit, or delete any post.";
break;
case 'author' : echo 'As an author, you can add, edit, or delete your own post';
break;
case 'editor' : echo 'As an editor, you can add or edit any post, and delete your own posts';
break;
default : echo "You do not have access to this page. Please contact your administrator.";
}
?>
Dylan Ryan
4,855 Points<?php
//Available roles: admin, editor, author, subscriber
if (!isset($role)) {
$role = 'subscriber';
}
switch($role){
case 'admin': echo 'As an admin, you can add, edit, or delete any post.';
break;
case 'editor' : echo 'As an editor, you can add or edit any post, and delete your own posts';
break;
case 'author' : echo 'As an author, you can add, edit, or delete your own post';
break;
default : echo 'You do not have access to this page. Please contact your administrator.';
}
?>
Tried that. Also to clarify - I am receiving the error : Bummer! I do not see a case for editor.
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! There are a couple of things going on here. The space between the case and the colon is causing the challenge to fail. You've written case 'editor' :
, but it wants to see case 'editor':
without the space. This is present in 3 out of 4 of the case statements. Also, each one of the strings should end with a full stop/period, but two of your strings are missing this.
I think you can get it with these hints, but let me know if you're still stuck!
Antonio De Rose
20,885 Pointsnothing wrong with the code, I guess, you gotta be exact on what is been printed and the other thing,
for the echo statements, editor and author, make sure finish with a full stop
other thing is, make sure, you are removing additional space for editor and author just before colon
case 'editor' : echo 'As an editor, you can add or edit any post, and delete your own posts';
break;
case 'author' : echo 'As an author, you can add, edit, or delete your own post';
break;
Antonio De Rose
20,885 PointsAntonio De Rose
20,885 PointsDo not see anything wrong in it, could you try editor and then author, as the question ask for editor and author.
BTW, do not mix the quotes, case 1 echo is with "", case 2 echo is with ''