UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

56 lines (48 loc) 1.54 kB
--- layout: page title: "JavaScript pclose function" comments: true sharing: true footer: true alias: - /functions/view/pclose:807 - /functions/view/pclose - /functions/view/807 - /functions/pclose:807 - /functions/807 --- <!-- Generated by Rakefile:build --> A JavaScript equivalent of PHP's pclose {% codeblock filesystem/pclose.js lang:js https://raw.github.com/kvz/phpjs/master/functions/filesystem/pclose.js raw on github %} function pclose (handle) { // http://kevin.vanzonneveld.net // + original by: Brett Zamir (http://brett-zamir.me) // * example 1: var handle = popen('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm', 'r'); // * example 1: pclose(handle); // * returns 1: true if (!handle || handle.opener !== 'popen') { return false; } try { delete this.php_js.resourceDataPointer[handle.id]; delete this.php_js.resourceData[handle.id]; // Free up memory } catch (e) { return false; } return true; } {% endcodeblock %} - [view on github](https://github.com/kvz/phpjs/blob/master/functions/filesystem/pclose.js) - [edit on github](https://github.com/kvz/phpjs/edit/master/functions/filesystem/pclose.js) ### Example 1 This code {% codeblock lang:js example %} var handle = popen('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm', 'r'); pclose(handle); {% endcodeblock %} Should return {% codeblock lang:js returns %} true {% endcodeblock %} ### Other PHP functions in the filesystem extension {% render_partial _includes/custom/filesystem.html %}