mklib Example/Test Page

mklib.php mklib.php ver 0.4.3

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
$f1: sample.txt
getFileExtension($f1): txt
$f2: sample.filename.test.txt
getFileExtension($f2): txt


getFilenameSansExt()

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

Example
$f1: sample.txt
getFilenameSansExt($f1): sample
$f2: sample.filename.test.txt
getFilenameSansExt($f2): sample.filename.test


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

Deprecated: Function eregi_replace() is deprecated in /home1/walkersanraz/public_html/blazonry.com/scripting/mklib/mklib.php on line 275
$str: This is a URL: http://www.blazonry.com/
procDisplayText($str): This is a URL: http://www.blazonry.com/


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

Deprecated: Function eregi_replace() is deprecated in /home1/walkersanraz/public_html/blazonry.com/scripting/mklib/mklib.php on line 246

Deprecated: Function eregi_replace() is deprecated in /home1/walkersanraz/public_html/blazonry.com/scripting/mklib/mklib.php on line 247

Deprecated: Function eregi_replace() is deprecated in /home1/walkersanraz/public_html/blazonry.com/scripting/mklib/mklib.php on line 249

Deprecated: Function eregi_replace() is deprecated in /home1/walkersanraz/public_html/blazonry.com/scripting/mklib/mklib.php on line 250
$str: Here's some text with <b>bold</b> tags and <? print "PHP"; ?> tags
procDBText($str,0)Here\'s some text with bold tags and tags
procDBText($str,1)Here\'s some text with bold tags and tags
procDBText($str,2)Here\'s some text with <b>bold</b> tags and <? print "PHP"; ?> tags


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
Counter: 01234567890123456789012345678901234567890
Original: This is my string, there are many like it but this one is mine.
Cut String: This is my string, there are many like...


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
Bytes 1: 123456789
Bytes 2: 25689
Bytes 2: 1024
Formatted B1: 117.7mb
Formatted B2: 25.0kb
Formatted B3: 1024




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
$mydate1: 3-26-99
$mydate2: 8-5-00
$mydate3: 10-15-01
procDate($mydate1): 1999-03-26
procDate($mydate2): 2000-08-05
procDate($mydate3): 2001-10-15


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
$mydate: 2000-12-5
procDate($mydate): 12-5-2000


 

blazonry.com
Last Updated: 2001-08-22