Changeset 792 for branches/1.1dev/lib


Ignore:
Timestamp:
Apr 10, 2023 10:42:00 PM (13 months ago)
Author:
anonymous
Message:

Backport dump() function from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1dev/lib/Utilities.inc.php

    r760 r792  
    1818define('SC_DUMP_VAR_DUMP', 1);
    1919define('SC_DUMP_VAR_EXPORT', 2);
     20define('SC_DUMP_JSON', 3);
    2021function dump($var, $display=false, $dump_method=SC_DUMP_PRINT_R, $file='', $line='')
    2122{
    2223    if ('cli' === php_sapi_name() || defined('_CLI')) {
    23         echo "DUMP FROM: $file $line\n";
     24        echo ('' != $file . $line) ? "DUMP FROM: $file $line\n" : "DUMP:\n";
    2425    } else {
    2526        echo $display ? "\n<br />DUMP <strong>$file $line</strong><br /><pre>\n" : "\n<!-- DUMP $file $line\n";
     
    5152    case SC_DUMP_VAR_EXPORT:
    5253        var_export($var);
     54        break;
     55
     56    case SC_DUMP_JSON:
     57        echo json_encode($var, JSON_PRETTY_PRINT);
    5358        break;
    5459    }
Note: See TracChangeset for help on using the changeset viewer.