-1

When I Put html tag into html file, I can warp them by CDATA. I want to display <?php ... ?> tag as content in php file too.

CDATA rule is run on client side, can't help for PHP. Now I am using &lt; and &gt; to replace the < and >.

Is there any better idea to show the php code?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Zitty Yam
  • 135
  • 1
  • 12

1 Answers1

1

Store whatever data you wish to be displayed as a string variable in PHP:

$x = "<?php my awesome PHP code lies here ?>";

and use htmlentities function to output the data:

echo htmlentities( $x );
hjpotter92
  • 78,589
  • 36
  • 144
  • 183