You are here

function httprl_print_empty in HTTP Parallel Request & Threading Library 6

Same name and namespace in other branches
  1. 7 httprl.module \httprl_print_empty()

If $data is bool or strlen = 0 use var_export. Recursively go deeper.

Parameters

mixed $data: Data In.

int $level: (optional) At what level of the array/object are we at.

Return value

mixed $data

1 call to httprl_print_empty()
httprl_pr in ./httprl.module
Pretty print data.

File

./httprl.module, line 2769
HTTP Parallel Request Library module.

Code

function httprl_print_empty(&$data, $level = 0) {
  $level++;
  if ($level < 5) {
    if (is_object($data)) {
      $new_object = new stdClass();
      $new_object->__original_class_name__ = get_class($data);
      foreach ($data as $key => $values) {
        $new_object->{$key} = httprl_print_empty($values, $level);
      }
      $data = $new_object;
    }
    elseif (is_array($data)) {
      foreach ($data as &$values) {
        $values = httprl_print_empty($values, $level);
      }
    }
    elseif (is_bool($data) || strlen((string) $data) == 0) {
      $data = strtoupper(var_export($data, TRUE));
    }
    elseif (is_string($data) && strlen($data) > HTTPRL_PR_MAX_STRING_LENGTH) {

      // Do not try to print a string longer than 256KB.
      // Some browsers have issues with very long documents.
      $data = substr($data, 0, HTTPRL_PR_MAX_STRING_LENGTH);
    }
  }
  return $data;
}