Added to_string global function

This commit is contained in:
Timothy Warren 2012-01-27 12:55:58 -05:00
parent f07658652e
commit a5474c9d56

View File

@ -354,7 +354,49 @@ function site_url($segment)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/**
* Prints out the contents of the object
*
* @param object/array $data
* @param string $method
* @return string
*/
function to_string($data, $method='print_r')
{
$output = '<pre>';
if($method == "var_dump")
{
ob_start();
var_dump($data);
$output .= ob_get_contents();
ob_end_clean();
}
else if($method == "var_export")
{
ob_start();
var_export($data);
$output .= ob_get_contents();
ob_end_clean();
}
else
{
$output .= print_r($data, TRUE);
}
return $output . '</pre>';
}
// --------------------------------------------------------------------------
// Wrapper workaround for PHP < 5.4
function do_include($path)
{
require_once($path);
}
// Load Most Common libraries // Load Most Common libraries
array_map('require_once', glob(SYS_PATH.'*.php')); array_map('do_include', glob(SYS_PATH.'*.php'));
// End of common.php // End of common.php