pclib  2.3.2
Lightweight PHP framework
Functions
Func.php File Reference

PClib constants, global functions and variables. More...

Functions

 paramstr ($str, $param, $keepEmpty=false)
 Placeholders in string $str will be replaced with values from $param array. More...
 
 dump ()
 Dump variable(s) for debugging and stop application. More...
 
 jdump ()
 Dump variable(s) for debugging to the javascript console. More...
 
 logdump ()
 Dump variable(s) for debugging to the text file / database log. More...
 
 pri ($id)
 Return string "ID='$id'". More...
 
 extractpath ($path, $format)
 Return part of the filesystem path. More...
 
 mkident ($s, $options= '')
 Convert string to identificator. More...
 
 str_shift ($separ, &$str)
 Similar to array_shift() but for string. More...
 
 pcl_ident ($str)
 Convert string to pcl identificator, valid for system purposes. More...
 
 mimetype ($path)
 Return mime-type of the file $path. More...
 
 filedata ($path, $force_download=false, $filename=null)
 Send file $path to output through php (so real path to file is hidden). More...
 
 randomstr ($size, $characters= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
 Return string of size $size with random characters.
 

Detailed Description

PClib constants, global functions and variables.

Author
-dk- lenoc.nosp@m.hwar.nosp@m.e@gma.nosp@m.il.c.nosp@m.om http://pclib.brambor.net/

Function Documentation

dump ( )

Dump variable(s) for debugging and stop application.

Usage: dump($a,$b,...);

extractpath (   $path,
  $format 
)

Return part of the filesystem path.

Format can use placeholders d directory, f filename, e extension. Example: extractpath($path, "%f.%e"); //return "filename.extension"

filedata (   $path,
  $force_download = false,
  $filename = null 
)

Send file $path to output through php (so real path to file is hidden).

You can force browser download dialog or show file name as $filename.

jdump ( )

Dump variable(s) for debugging to the javascript console.

Usage: jdump($a,$b,...);

logdump ( )

Dump variable(s) for debugging to the text file / database log.

Usage: logdump($a,$b,...);

mimetype (   $path)

Return mime-type of the file $path.

It uses linux command 'file', so it works only on *nix with exec() allowed. On windows you can set array of extension => mime-type pairs into pclib.mimetypes config variable.

mkident (   $s,
  $options = '' 
)

Convert string to identificator.

Convert characters to ascii and remove other characters. You can set words separator or convert to uppercase/lowercase.

Parameters
string$sinput text
string$optionsex: '' : camelcase, '-' : 'camel-case', '_U': CAMEL_CASE etc.
Returns
string $identificator
paramstr (   $str,
  $param,
  $keepEmpty = false 
)

Placeholders in string $str will be replaced with values from $param array.

Format is the same like for template file.
Ex: print paramstr("{A} is {B}", array('A' => 'pclib', 'B' => 'best'));
$param can be two-dimensional array of n-rows, each row is formated with string $str.

Parameters
string$strstring with {PARAM} parameters (placeholders)
array$paramassociative array PARAM=>VALUE
bool$keepEmptyKeep (don't delete) tags undefined in $param
Returns
string $str
pcl_ident (   $str)

Convert string to pcl identificator, valid for system purposes.

Reduce input text to alphanumeric characters plus underscore, dot and hyphen

Parameters
string$strinput text
Returns
string $identificator system correct
pri (   $id)

Return string "ID='$id'".

Helper for db queries on primary key.
Ex: $db->select('PRODUCTS', pri($id));

str_shift (   $separ,
$str 
)

Similar to array_shift() but for string.

Return beginning of the string to the separator $separ, shortening original $str