Tuesday, December 18, 2007

PHP Code View Highlighter

This uses php's highlight_string() function to highlight your php code.

<title>Color Coder</title>
<?php
if( isset( $_POST['content'] ) )
{
$php_code = highlight_string( stripslashes( $_POST['content'] ), true );
?>
<div style="background:#FFFFCC; border:2px solid #999999; width:550px;">
<!-- Start Code -->
<?php echo $php_code . "\n"; ?>
<!-- End Code -->
</div>
<br />
<?php
}
?>
<form method="post" action="">
<textarea name="content" rows="15" cols="45"><?php echo stripslashes( $_POST['content'] ); ?></textarea>
<br />
<input type="submit" value="Color Me!" />
</form>
Just type in your <strong>PHP</strong> code that you would like to be color coded

No comments: