Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,662 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,662 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