How can variables be used to display PHP code without executing it?

To display PHP code without executing it, you can store the PHP code as a string in a variable and then echo the variable. This way, the PHP code will be displayed as plain text without being executed.

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