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 trialLinda Wohlgemuth
2,510 PointsCan't find my mistake in Code Challange Operators.
Hey there, I'm getting crazy - I just can't see why the system tells me to "Use the negation operator to check that $role is NOT EQUAL to "admin"" - I thought I did!
In the Preview everything works fine....
Thank you for your help!
<?php
$username = 'sketchings';
//Available roles: author, editor, admin
$role = 'editor';
//add conditional statement
if (isset($username) && $role!='admin') {echo "You do not have access to this page. Please contact your administrator.";}
?>
Linda Wohlgemuth
2,510 PointsThanks for your reply Mihkel Pajunen. Yes that's the intended behavior. And it works in the Console. But the Code-Challange-System doesn't let me go on with this solution. So I began to doubt ... you know I'm a noob in PHP ;)
Linda Wohlgemuth
2,510 PointsOK now I finally got It. There where only some blanks missing. Before and after != I don't think they're necessary outside this challange, are they?
1 Answer
Mihkel Pajunen
8,017 PointsYou don't have to include a space before and after the operator, but it makes your code more readable, which is always a good thing. Although your code executes either way, you want to pick up good coding practices, such as applying proper spacing.
Mihkel Pajunen
8,017 PointsMihkel Pajunen
8,017 PointsI think that your program functions as intended. Since your username is set and your role is assigned a string of "editor", your program outputs: "You do not have access to this page. Please contact your administrator.", just as it should. Is this not intended behavior?