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 trial

PHP PHP Basics (Retired) PHP Datatypes PHP Constants

isset($bar);

$bar = 0;
isset($bar);

will return TRUE, not FALSE.

3 Answers

Chris Shaw
Chris Shaw
26,676 Points

The 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';
}

Thanks 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
Chris Shaw
26,676 Points

I just looked at the video and indeed it's using the isset function is the wrong way. /cc Hampton Paulk

I will fix. Good Catch.

Ryan Hellerud
Ryan Hellerud
3,635 Points

also where are the notes with the docs you say you leave docs in notes but I dont see them /cc Hampton Paulk