Bird
0
0

What will be the output of this code?

medium📝 state output Q4 of 15
Wordpress - WordPress Settings and Configuration
What will be the output of this code?
update_option('site_mode', 'live');
$mode = get_option('site_mode', 'test');
echo $mode;
Anull
Btest
Csite_mode
Dlive
Step-by-Step Solution
Solution:
  1. Step 1: Understand update_option()

    It sets 'site_mode' to 'live' in the database.
  2. Step 2: Understand get_option() with default

    Since 'site_mode' exists, get_option returns 'live', ignoring default 'test'.
  3. Final Answer:

    live -> Option D
  4. Quick Check:

    Updated option value is returned by get_option() [OK]
Quick Trick: get_option() returns updated value if exists, else default [OK]
Common Mistakes:
  • Assuming default value is always returned
  • Confusing option name with value
  • Expecting null if option exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes