#native_company# #native_desc#
#native_cta#

Document your PHP scripts Realtime

By Dustin Schneider
on August 29, 2000

In response to Stefano Locati’s “How to Document Your PHP classes”, I created a quick & simple PHP script which will parse other PHP3 files and create some basic documentation. The advantage to this is, it can be placed under any comment — plus it’s very extendable.

The current scripts recognises these commands:

@@ = Header
%% = Description
!! = Horizontal Line 
;  = End of decleration. 

For example:

/*
@@this_function($var1, $var2);
%%This function takes 2 variables and does absolutely nothing with them.;
!!
*/

Would produce something like this:

this_function($var1, $var2)

Description: This function takes 2 variables and does absolutely nothing with them.
(horizontal line here)


$filename = "FILENAME_HERE";

$fp = fopen($filename, "r");
$buffer = fread($fp, filesize($filename));
fclose($fp);

for($i=0; $i<strlen($buffer); $i++)
{
 // Header
 if ($buffer[$i] == '@' && $buffer[$i+1] == '@')
 {
  echo "

"; $i++; while($buffer[$i++] != ';') { if ($buffer[$i] == ';') break; echo $buffer[$i]; } echo "

"; } // Description if ($buffer[$i] == '%' && $buffer[$i+1] == '%') { echo "Description: "; $i++; while($buffer[$i++] != ';') { if ($buffer[$i] == ';') break; echo $buffer[$i]; } echo "
"; } if ($buffer[$i] == '!' && $buffer[$i+1] == '!') { echo "<hr></hr>"; } }

Dustin Schneider