the simplest way I know is to set a placeholder with the needed info, then print the results in another snippet.
For example: I added a snippet to the top of the template before anything else with this code -
[!SendVariable!]
<?php
$sentvariable ="yes";
$modx -> setPlaceholder('sentvariable', $sentvariable);
?>
This will set up a placeholder to use later in the script and will print the word
yes
wherever you add the placeholder tags - [+sentvariable+]
$output .="[+sentvariable+]";
// prints "yes"
a simple example, but it can be modified any way you need...
also have a look here:
http://wiki.modxcms.com/index.php/API:setPlaceholder