For non html output
echo esc_html($dosomething);
For output with html content
echo wp_kses_post($dosomething);