UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

54 lines (46 loc) 1.77 kB
--- layout: page title: "JavaScript runkit_import function" comments: true sharing: true footer: true alias: - /functions/view/runkit_import:812 - /functions/view/runkit_import - /functions/view/812 - /functions/runkit_import:812 - /functions/812 --- <!-- Generated by Rakefile:build --> A JavaScript equivalent of PHP's runkit_import {% codeblock runkit/runkit_import.js lang:js https://raw.github.com/kvz/phpjs/master/functions/runkit/runkit_import.js raw on github %} function runkit_import (file, flags) { // http://kevin.vanzonneveld.net // + original by: Brett Zamir (http://brett-zamir.me) // - depends on: file_get_contents // % note 1: does not return an associative array as in PHP and will evaluate all variables, not only those in a function or class // % note 2: Implement instead with include? // * example 1: runkit_import('http://example.com/somefile.js'); // * returns 1: undefined if (flags) { // RUNKIT_IMPORT_FUNCTIONS, RUNKIT_IMPORT_CLASS_METHODS, RUNKIT_IMPORT_CLASS_CONSTS, // RUNKIT_IMPORT_CLASS_PROPS, RUNKIT_IMPORT_CLASSES, RUNKIT_IMPORT_OVERRIDE // CLASSKIT_AGGREGATE_OVERRIDE ? throw 'Flags not supported for runkit_import'; } eval(this.file_get_contents(file)); } {% endcodeblock %} - [view on github](https://github.com/kvz/phpjs/blob/master/functions/runkit/runkit_import.js) - [edit on github](https://github.com/kvz/phpjs/edit/master/functions/runkit/runkit_import.js) ### Example 1 This code {% codeblock lang:js example %} runkit_import('http://example.com/somefile.js'); {% endcodeblock %} Should return {% codeblock lang:js returns %} undefined {% endcodeblock %} ### Other PHP functions in the runkit extension {% render_partial _includes/custom/runkit.html %}