From a5474c9d5696f9dc2d9a3f5fda4a32fda63b6881 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Jan 2012 12:55:58 -0500 Subject: [PATCH] Added to_string global function --- src/sys/common.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/sys/common.php b/src/sys/common.php index 37e6eed..aea85bc 100644 --- a/src/sys/common.php +++ b/src/sys/common.php @@ -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 = '
';
+	
+	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 . '
'; +} + +// -------------------------------------------------------------------------- + +// Wrapper workaround for PHP < 5.4 +function do_include($path) +{ + require_once($path); +} + // Load Most Common libraries -array_map('require_once', glob(SYS_PATH.'*.php')); +array_map('do_include', glob(SYS_PATH.'*.php')); + // End of common.php \ No newline at end of file