How can PHP code be displayed as text without being executed in PHP?

To display PHP code as text without it being executed, you can use the `htmlspecialchars()` function to encode the PHP tags and prevent them from being interpreted by the PHP parser. This will display the PHP code as plain text on the webpage.

<?php
$phpCode = '<?php echo "Hello, World!"; ?>';
echo htmlspecialchars($phpCode);
?>