jQuery – php code – Plugin

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)


2 thoughts on “jQuery – php code – Plugin

  1. phpman sagt:

    Hey, can this apply to textarea also?

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *