Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Talk:Function Reference/get option

What does this function return? Is it false if the option doesn't exist? Samwilson 12:09, 30 May 2007 (UTC)

Yeah, it does return false. Shamess 15:07, 15 April 2008 (UTC)

I've noticed that when I create an option, but no value is assigned to it (just an empty string or whatnot, "") that when I try to call get_option it I get a return of FALSE even though it exists in the database (i.e. calling get_option('option') returns false when the key exists, but no value is associated with it). Is that the way it's supposed to work? --Mogman1 21:21, 21 July 2008 (UTC)

This should perhaps be expanded...

This function will unserialize data passed to it, if it detects a serialized string. See maybe_unserialize() in the same file.

Perhaps a note should be made here to clarify that for developers?

I didn't expect this behavior and so was serializing my own data and couldn't understand why I was having problems unserializing it until I read the function source. Nullvariable 17:26, 25 February 2011 (UTC)


Added that under the notes section. J.D. Grimes 20:44, 9 July 2013 (UTC)