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 trialangelacarabelas
1,451 Pointsisset and operator functions
Hi everyone, the challenge task following the logical operators video requires an "isset" function to be used, but it was not mentioned in the video or the teachers notes as I saw. I was only able to answer it based on the information in the community posts. Am I missing something or was there information missing?
<?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 administratior.";
}
2 Answers
Colin V
5,784 PointsYou can actually get this to work a couple different ways:
<?php
if($username != '' && $role != "admin") {
echo "You do not have access to this page. Please contact your administratior.";
}
Or even
<?php
if(!empty($username) && $role != "admin") {
echo "You do not have access to this page. Please contact your administratior.";
}
The first is pretty simple, just saying username isn't an empty string (or, plainly, two single quotes with nothing between), the second uses a function I'm sure she has used before (although, not sure if it's been used in this track).
angelacarabelas
1,451 Pointsthank you so much!!!
Colin V
5,784 PointsYou're welcome!