UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

54 lines (45 loc) 1.67 kB
--- layout: page title: "JavaScript fpassthru function" comments: true sharing: true footer: true alias: - /functions/view/fpassthru:804 - /functions/view/fpassthru - /functions/view/804 - /functions/fpassthru:804 - /functions/804 --- <!-- Generated by Rakefile:build --> A JavaScript equivalent of PHP's fpassthru {% codeblock filesystem/fpassthru.js lang:js https://raw.github.com/kvz/phpjs/master/functions/filesystem/fpassthru.js raw on github %} function fpassthru (handle) { // http://kevin.vanzonneveld.net // + original by: Brett Zamir (http://brett-zamir.me) // * example 1: fopen('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm', 'r'); // * example 1: fpassthru(handle); // * returns 1: 3 if (!this.php_js || !this.php_js.resourceData || !this.php_js.resourceDataPointer || !handle || !handle.id) { return false; } var chrs = this.php_js.resourceData[handle.id].slice(this.php_js.resourceDataPointer[handle.id]); this.echo(chrs); this.php_js.resourceDataPointer[handle.id] = this.php_js.resourceData[handle.id].length; // Place pointer at end return chrs; } {% endcodeblock %} - [view on github](https://github.com/kvz/phpjs/blob/master/functions/filesystem/fpassthru.js) - [edit on github](https://github.com/kvz/phpjs/edit/master/functions/filesystem/fpassthru.js) ### Example 1 This code {% codeblock lang:js example %} fopen('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm', 'r'); fpassthru(handle); {% endcodeblock %} Should return {% codeblock lang:js returns %} 3 {% endcodeblock %} ### Other PHP functions in the filesystem extension {% render_partial _includes/custom/filesystem.html %}