UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

54 lines (45 loc) 1.72 kB
--- layout: page title: "JavaScript ob_get_length function" comments: true sharing: true footer: true alias: - /functions/view/ob_get_length:897 - /functions/view/ob_get_length - /functions/view/897 - /functions/ob_get_length:897 - /functions/897 --- <!-- Generated by Rakefile:build --> A JavaScript equivalent of PHP's ob_get_length {% codeblock outcontrol/ob_get_length.js lang:js https://raw.github.com/kvz/phpjs/master/functions/outcontrol/ob_get_length.js raw on github %} function ob_get_length () { // http://kevin.vanzonneveld.net // + original by: Brett Zamir (http://brett-zamir.me) // * example 1: ob_get_length(); // * returns 1: 155 this.php_js = this.php_js || {}; var phpjs = this.php_js, ini = phpjs.ini, obs = phpjs.obs; if (!obs || !obs.length) { return (ini && ini['output_buffering'] && (typeof ini['output_buffering'].local_value !== 'string' || ini['output_buffering'].local_value.toLowerCase() !== 'off')) ? 0 : false; // If output was already buffered, it would be available in obs } // Fix: WIll probably need to change depending on Unicode semantics return obs[obs.length - 1].buffer.length; // Retrieve length of most recently added buffer contents } {% endcodeblock %} - [view on github](https://github.com/kvz/phpjs/blob/master/functions/outcontrol/ob_get_length.js) - [edit on github](https://github.com/kvz/phpjs/edit/master/functions/outcontrol/ob_get_length.js) ### Example 1 This code {% codeblock lang:js example %} ob_get_length(); {% endcodeblock %} Should return {% codeblock lang:js returns %} 155 {% endcodeblock %} ### Other PHP functions in the outcontrol extension {% render_partial _includes/custom/outcontrol.html %}