Skip to content

Instantly share code, notes, and snippets.

@AlekVolsk
Last active March 17, 2021 09:14
Show Gist options
  • Save AlekVolsk/faa8d9ab6def28935533e7530b3d3279 to your computer and use it in GitHub Desktop.
Save AlekVolsk/faa8d9ab6def28935533e7530b3d3279 to your computer and use it in GitHub Desktop.
<?php
function vd(...$args)
{
print_r('<pre style="margin:0;padding:20px;font:14px/1.6 Consolas,monospace;' .
'background-color:#eee;color:#333">===<br>');
foreach ($args as $i => $context) {
if ($i > 0) {
print_r('<br>===<br><br>');
}
print_r('<b>Parameter ' . $i . ' (' . gettype($context) . '):</b><br>');
if (!(bool)$context) {
var_dump($context);
} else {
print_r($context);
}
}
print_r('<br>===</pre>');
}
function vdr(...$args)
{
ob_start();
vd($args);
return ob_get_clean();
}
function savefile($fname, $val)
{
$file = fopen($fname, 'w');
fwrite($file, print_r($val, true));
flush();
fclose($file);
}
function savetempfile($val)
{
$file = fopen(\Joomla\CMS\Factory::getConfig()->get('tmp_path') . '/dump.log', 'w');
fwrite($file, print_r($val, true));
flush();
fclose($file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment