mklib Example/Test Page

mklib.php

The latest version of the mklib.php library and this example page is at
mklib.php home: http://blazonry.com/scripting/mklib

File Functions

getFileExtension()

Parses the passed filename and returns just the extension, defined by everything after the last period.

Example
\n"; print "\n"; print "\n"; print "\n"; ?>
\$f1: $f1
getFileExtension(\$f1): " . getFileExtension($f1) . "
\$f2: $f2
getFileExtension(\$f2): " . getFileExtension($f2) . "


getFilenameSansExt()

Parses the passed filename and returns just the filename portion without the extension.

Example
\n"; print "\n"; print "\n"; print "\n"; ?>
\$f1: $f1
getFilenameSansExt(\$f1): " . getFilenameSansExt($f1) . "
\$f2: $f2
getFilenameSansExt(\$f2): " . getFilenameSansExt($f2) . "


Text Functions

procDisplayText()

Formats text to be displayed in a browser. It converts line breaks to <br> and converts http://(.*) to live HTML links.

Example
\n"; print "\n"; ?>
\$str: $str
procDisplayText(\$str): " . procDisplayText($str) . "


procDBText()

Prepares a string for inserting into a database. Depending on the different settings (0,1,2) it allows for different HTML tags to be inserted.
0 - Allows No HTML or PHP tags 1 - Allows for B,I, 2 -

Example
bold tags and tags'; print "\n"; print "\n"; print "\n"; print "\n"; ?>
\$str: ".htmlentities($str)."
procDBText(\$str,0)".procDBText($str,0)."
procDBText(\$str,1)".procDBText($str,1)."
procDBText(\$str,2)".procDBText($str,2)."


mk_substr()

Chops a string close to the given length, trying to make the cut at a space. It moves backwards cutting more than the specified length.

Example
\n"; print "\n"; print "\n"; ?>
Counter: $pos
Original: $str
Cut String: $cutstr


format_bytes()

Formats passed bytes into a more human readable format, converting to "kb" and "mb" when appropiate, kinda like the -h option for df or ls.

Example
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; ?>
Bytes 1: $b1
Bytes 2: $b2
Bytes 2: $b3
Formatted B1: ".format_bytes($b1)."
Formatted B2: ".format_bytes($b2)."
Formatted B3: ".format_bytes($b3)."




mk_datetime.php testing

Date/Time Functions

procDate()

Converts a passed date in varying mm-dd-yyyy formats into a sql compatible yyyy-mm-dd. If a two-digit year is passed to it is assumed to be 19xx if greater than 70, and 20xx if not. Used before inserting dates into database.

Example
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; ?>
\$mydate1: $mydate1
\$mydate2: $mydate2
\$mydate3: $mydate3
procDate(\$mydate1): ".procDate($mydate1)."
procDate(\$mydate2): ".procDate($mydate2)."
procDate(\$mydate3): ".procDate($mydate3)."


revDate()

Reverses a SQL date from yyyy-mm-dd to mm-dd-yyyy, the common US date format. Used for displaying dates grabbed from database.

Example
\n"; print "\n"; ?>
\$mydate: $mydate
procDate(\$mydate): ".revDate($mydate)."


 

blazonry.com
Last Updated: 2001-08-22