Echo PHP tags with php

Hello, I’d like to echo a piece of code someone could copy and past into the front end of a website. The backend will need to output little snippets of code and I’m not sure how to do something like

<?php

echo “<?php”;

echo “$result = …”;

echo “?>”;

?>

See how this might not work? Well it doesn’t, so does anyone know a workaround. Thanks!