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 trialantoniodevita
5,982 PointsCode php , help me ???
Add a check for the role of "editor" and display the following message: As an editor, you can add or edit any post, and delete your own posts. Add a check for the role of "author" and display the following message: As an author, you can add, edit, or delete your own post.
Please , help me with this challenge
<?php
//Available roles: admin, editor, author, subscriber
if (!isset($role)) {
$role = 'subscriber';
}
//change to switch statement
switch ($role) { case 'admin':
echo "As an admin, you can add, edit, or delete any post.";
break;
default: echo "You do not have access to this page. Please contact your administrator.";
}
?>
1 Answer
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi Antonio,
This is a very simple challenge in many respects as the Switch statement and it's keywords has been provided for you. You just need to add to it.
So you have to add 2 more "checks" which are simply new "cases" in your Switch statement. Pay attention to what strngs you need to add and for which case. You'll need to match the strings exactly to pass the challenge.
<?php
case 'role':
//code goes here
echo "strong";
break;
So each new case goes inside the Switch statement as it's own code block but before the final default:
case. Don't forget to add the break
keyword after each case. Good luck!