---
layout: page
title: "JavaScript ob_list_handlers function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/ob_list_handlers:900
- /functions/view/ob_list_handlers
- /functions/view/900
- /functions/ob_list_handlers:900
- /functions/900
---
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's ob_list_handlers

{% codeblock outcontrol/ob_list_handlers.js lang:js https://raw.github.com/kvz/phpjs/master/functions/outcontrol/ob_list_handlers.js raw on github %}
function ob_list_handlers () {
  // http://kevin.vanzonneveld.net
  // +   original by: Brett Zamir (http://brett-zamir.me)
  // *     example 1: ob_list_handlers();
  // *     returns 1: ['default output handler', 'myOwnHandler']

  var i = 0,
    arr = [],
    name = '',
    cbname = '';
  var getFuncName = function (fn) {
    var name = (/\W*function\s+([\w\$]+)\s*\(/).exec(fn);
    if (!name) {
      return '(Anonymous)';
    }
    return name[1];
  };

  this.php_js = this.php_js || {};
  var phpjs = this.php_js,
    ini = phpjs.ini;

  if (!phpjs.obs || !phpjs.obs.length) {
    if (ini && ini['output_buffering'] && (typeof ini['output_buffering'].local_value !== 'string' || ini['output_buffering'].local_value.toLowerCase() !== 'off')) {
      return ['default output handler']; // PHP doesn't return output_handler ini, even if it is set
    }
    return arr;
  }
  for (i = 0; i < phpjs.obs.length; i++) {
    cbname = getFuncName(phpjs.obs[i].callback);
    name = cbname === '' ? 'default output handler' : cbname === 'URLRewriter' ? 'URL-Rewriter' : cbname;
    arr.push(name);
  }
  return arr;
}
{% endcodeblock %}

 - [view on github](https://github.com/kvz/phpjs/blob/master/functions/outcontrol/ob_list_handlers.js)
 - [edit on github](https://github.com/kvz/phpjs/edit/master/functions/outcontrol/ob_list_handlers.js)

### Example 1
This code
{% codeblock lang:js example %}
ob_list_handlers();
{% endcodeblock %}

Should return
{% codeblock lang:js returns %}
['default output handler', 'myOwnHandler']
{% endcodeblock %}


### Other PHP functions in the outcontrol extension
{% render_partial _includes/custom/outcontrol.html %}
