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 trialAdam Tatusko
16,589 Pointsisset($bar);
$bar = 0;
isset($bar);
will return TRUE, not FALSE.
3 Answers
Chris Shaw
26,676 PointsThe isset
function checks if the given variable exists in the current scope, I assume by the code you have above you're wanting to check if the value of $bar
equals 0 which you can do by using an equality operator.
<?php
$bar = 0;
if ($bar === 0) {
echo '$bar does equal 0';
} else {
echo '$bar does not equal 0';
}
Adam Tatusko
16,589 PointsThanks for the info, but I was just commenting on the incorrect teaching at the beginning of the associated PHP video on PHP Constants.
Chris Shaw
26,676 PointsI just looked at the video and indeed it's using the isset
function is the wrong way. /cc Hampton Paulk
Hampton Paulk
5,093 PointsI will fix. Good Catch.
Ryan Hellerud
3,635 Pointsalso where are the notes with the docs you say you leave docs in notes but I dont see them /cc Hampton Paulk