UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

48 lines (40 loc) 1.44 kB
--- layout: page title: "JavaScript readfile function" comments: true sharing: true footer: true alias: - /functions/view/readfile:809 - /functions/view/readfile - /functions/view/809 - /functions/readfile:809 - /functions/809 --- <!-- Generated by Rakefile:build --> A JavaScript equivalent of PHP's readfile {% codeblock filesystem/readfile.js lang:js https://raw.github.com/kvz/phpjs/master/functions/filesystem/readfile.js raw on github %} function readfile (filename, use_include_path, context) { // http://kevin.vanzonneveld.net // + original by: Brett Zamir (http://brett-zamir.me) // - depends on: echo // * example 1: readfile('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm'); // * returns 1: '123' var read_data = this.file_get_contents(filename, use_include_path, context); // bitwise-or use_include_path? this.echo(read_data); return read_data; } {% endcodeblock %} - [view on github](https://github.com/kvz/phpjs/blob/master/functions/filesystem/readfile.js) - [edit on github](https://github.com/kvz/phpjs/edit/master/functions/filesystem/readfile.js) ### Example 1 This code {% codeblock lang:js example %} readfile('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm'); {% endcodeblock %} Should return {% codeblock lang:js returns %} '123' {% endcodeblock %} ### Other PHP functions in the filesystem extension {% render_partial _includes/custom/filesystem.html %}