function debug($var, $info = false) {
ob_start();
print_r($var);
$debug = "\n>>> [ " . basename($_SERVER['PHP_SELF']) . ($info ? ': ' . $info : '') . " ]\n" . ob_get_contents();
ob_end_clean();
$stderr = fopen("php://stderr", "w");
fwrite($stderr, $debug);
fclose($stderr);
}