{feature 'search2'} renders its content while the flag is on for this visitor, and the part after its own {else} - or the @else@ half - while it is off. The flags are the setting $padFeatures, normally in _config/config.php, name => what decides it:

padFeatureOverride ( 'search2', TRUE ) fixes a flag for the rest of the request, whatever the setting says - for a test or a preview - and padFeature ( 'search2' ) asks from PHP. A name that is no flag is FALSE and, under the strict check, an error.

A share depends on the visitor, so that example is shown, not run.