The e function runs PHP's htmlspecialchars function with the double_encode option set to true by default:
<?php echo e('<html>foo</html>');