public static function grid ($value, $title = '', $maxDepth = 1, $excludeProps = [], $excludeEmpty = false,
                               $depth = 0)
  {
    if (is_null ($value) || is_scalar ($value))
      return self::toString ($value);
    if ($depth >= $maxDepth)
      return "<i>(...)</i>";

    if (is_object ($value)) {
      if (method_exists ($value, '__debugInfo'))
        $value = $value->__debugInfo ();
      else $value = get_object_vars ($value);
    }
    if ($title) $title = "<p><b>$title</b></p>";

    // Exclude some properties ($excludeProps) from $value.
    $value = array_diff_key ($value, array_fill_keys ($excludeProps, false));
    if ($excludeEmpty)
      $value = array_prune_empty ($value);

    return $value ? "$title<table class=__console-table><colgroup><col width=160><col width=100%></colgroup>
" . implode ('',
        map ($value, function ($v, $k) use ($depth, $maxDepth, $excludeProps, $excludeEmpty) {
          $v = self::grid ($v, '', $maxDepth, $excludeProps, $excludeEmpty, $depth + 1);
          return "<tr><th>$k<td>$v";
        })) . "
</table>"
      : '<i>[]</i>';
  }