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 trialChris Stuntz
13,160 Pointsstuck on crud with the wordpress options table part 2
I must be seeing something here! This appears correct to me! but it is not passing!
require('includes/page-wrapper.php');
$options = get_option('my_plugin_options');
if( $options != ''){ $my_plugin_username = $options['my_plugin_username']; }
5 Answers
Chris Stuntz
13,160 PointsCompleted! I should have used !empty instead of !=
Matt Campbell
9,767 PointsWhat's this?
$options != ''
If options doesn't equal what?
Chris Stuntz
13,160 Pointsthe conditional test if the options array is not blank
Asim Qasimzade
9,015 PointsYou should use isset() function instead of $options != "" or $options != empty
if (isset($options)){
$my_plugin_username = $options ['my_plugin_username'];
}
james white
78,399 PointsDon't use:
!empty
It's just:
$options = get_option('my_plugin_options');
if( $options != '' ) {
$wptreehouse_username = $options['wptreehouse_username'];
}
From nejc's answer here:
https://teamtreehouse.com/forum/im-getting-the-white-screen-of-death