jQuery – php code – Plugin

April 23rd, 2008 08:37 Uhr von Ronald

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

jQuery(”.phpCode”).phpCode();

Usage example 2:

Using alternative AJAX URL: /ajax/ajax.phpcode.php

jQuery(”.phpCode”).phpCode(”/ajax/ajax.phpcode.php”);

Download:

jquery.phpcode.js (JavaScript-File)

jquery.phpcode.zip (Package with JavaScript-File and PHP-AJAX-Script)


Teile und genieße Diese Icons verzweigen auf soziale Netzwerke bei denen Nutzer neue Inhalte finden und mit anderen teilen können.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists

Geschrieben in PHP | 1 Kommentar »

1 Kommentar

  1. PHP Code Highlighting mit jQuery | Web Developer Blog Sagt:

    [...] jQuery – php code – Plugin [...]

Einen Kommentar abgeben

Bitte beachte: Die Kommentare werden moderiert. Dies kann zu Verzögerungen bei Deinem Kommentar führen. Es besteht kein Grund den Kommentar erneut abzuschicken.

*
To prove you're a person (not a spam script), type the answer to the math equation shown in the picture. Click on the picture to hear an audio file of the equation.
Click to hear an audio file of the anti-spam equation