mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
making pr() usable in terminal
This commit is contained in:
parent
854f331094
commit
56a334146e
1 changed files with 6 additions and 5 deletions
|
@ -230,8 +230,10 @@ if (!function_exists('pluginSplit')) {
|
||||||
if (!function_exists('pr')) {
|
if (!function_exists('pr')) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print_r convenience function, which prints out <PRE> tags around
|
* print_r() convenience function
|
||||||
* the output of given array. Similar to debug().
|
*
|
||||||
|
* In terminals this will act the same as using print_r() directly, when not run on cli
|
||||||
|
* print_r() will wrap <PRE> tags around the output of given array. Similar to debug().
|
||||||
*
|
*
|
||||||
* @see debug()
|
* @see debug()
|
||||||
* @param array $var Variable to print out
|
* @param array $var Variable to print out
|
||||||
|
@ -239,9 +241,8 @@ if (!function_exists('pr')) {
|
||||||
*/
|
*/
|
||||||
function pr($var) {
|
function pr($var) {
|
||||||
if (Configure::read('debug') > 0) {
|
if (Configure::read('debug') > 0) {
|
||||||
echo '<pre>';
|
$template = php_sapi_name() !== 'cli' ? '<pre>%s</pre>' : '%s';
|
||||||
print_r($var);
|
echo sprintf($template, print_r($var, true));
|
||||||
echo '</pre>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue