-2

I have this code on my website:

<textarea name="code" cols="20" rows="5">
<?php
echo "Your IP is: ". $_SERVER["REMOTE_ADDR"]; 
?>
</textarea>

I want it so that it shows the code as text, not run it.

Can this be done?

Eric Carvalho
  • 54,385
Trevor Clarke
  • 892
  • 6
  • 18

2 Answers2

1

You can either wrap your code in <xmp> tags:

<xmp>html code</xmp>

Or use PHP's built in htmlentities function:

$hmtlcode='stuff';
echo htmlentities($htmlcode);
Just Lucky Really
  • 723
  • 2
  • 10
  • 21
0

You could remove the <?php starting and ?> ending tag

David
  • 145
  • 6