{sandbox}...{/sandbox} does what {code} does - renders
its content as PAD source in a separate engine pass - with the pass sandboxed. It is
{code sandbox} under a name of its own.
Sandboxed means: going in, the page's variables are hidden and the data, content, bool and
sequence stores are emptied; coming out, everything is restored and what the pass set is gone.
A field of the page is missing inside - write {echo $city ?? 'default'} when a
snippet may run either way - and a {push} made inside fills the pass's own stacks,
not the page's.
The pipe form, {echo $snippet | sandbox}, runs a value as a template in the
same isolation. It is the safer choice for template text that comes from outside the code -
an editor, a database - when that text should not read or change the page's state. It is not a
security boundary for untrusted authors on its own: the template language can still call what
$padPhpFunctions allows.