My first jQuery-Plugin passes PHP-Code from given elements (i.e. div-Containers) to an AJAX-Script which highlights the given code with the PHP builtin function highlight_string(). The returning highlighted string will be set back into the container it came from.
This plugin is nothing special but helpful for HTML-Documentation files. I use it to write down my PHP examples in simple HTML files without creating messy PHP files with code inside the code. ;-) It’s a clean and safe way and even nice for search engines. ;-)
Example 1:
$dh = mysql_connect(“localhost”, “user”, “pass”);
echo “hello world!”;
exit;
Example 2:
for($i = 0; $i < 53; $i++) {
print $i + 4 . '<br />';
}
Usage example 1:
Using default AJAX URL: ./phpcode.php
Usage example 2:
Using alternative AJAX URL: /ajax/ajax.phpcode.php
Download:
jquery.phpcode.js (JavaScript-File)
jquery.phpcode.zip (Package with JavaScript-File and PHP-AJAX-Script)
Pingback: PHP Code Highlighting mit jQuery | Web Developer Blog
Hey, can this apply to textarea also?