Home > PHP > PHP Code > How to highlight the source code in our php application?

How to highlight the source code in our php application?

Hi friends,

In our php application some times we want to highlight the source code to user friendly , so the following function helped you to highlight the source code.

<?php
if (!empty($_POST['text'])){
echo '<div style="border: solid 1px red; width:300px;height: 150px; padding: 20px; margin: 20px">';
highlight_string(stripslashes($_POST['text']));
echo '</div>';
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<textarea name="text" style="width: 300px; height: 150px;padding: 20px; margin: 20px"><?php echo stripslashes($_POST['text']);
?></textarea>
<br />
<input type="submit" />
</form>

The output of this code will be –

Code highlight in php application

Code highlight in php application

You may also like
Multi-language support for web application with MySql and PHP
How to add or remove file fields using jquery
How to calculate statistics in daily, weekly , monthly and yearly using php
How to rectify json_encode returns null in php web services

1 Response

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.