echo $site_name; if the option 'site_name' was previously saved as 'My Cool Site'?<?php $site_name = get_option('site_name', 'Default Site'); echo $site_name; ?>
The get_option function returns the saved value for the given option name. Since 'site_name' was saved as 'My Cool Site', that string is returned and echoed.
The correct function to update or add an option in WordPress is update_option. The other functions do not exist in WordPress.
<?php add_option('footer_text', 'Thank you for visiting!'); add_option('footer_text', 'New footer text'); ?>
The add_option function only adds a new option if it does not already exist. If the option exists, it does nothing and returns false. So the second call does not update the value.
$result?<?php update_option('color_scheme', 'dark'); $result = get_option('color_scheme', 'light'); ?>
The update_option sets the option 'color_scheme' to 'dark'. Then get_option retrieves it, so $result is 'dark'.
The Options API stores data in the wp_options table and is designed for small pieces of data like settings. It does not encrypt data automatically, does not require manual queries, and can store strings, arrays, and other serializable data.