JavaScript get_included_files
Returns an array with the file names that were included (includes require and once varieties)
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 2526 27 | function get_included_files () { // Returns an array with the file names that were included (includes require and once varieties) // // version: 909.322 // discuss at: http://phpjs.org/functions/get_included_files // + original by: Michael White (http://getsprink.com) // % note 1: Uses global: php_js to keep track of included files // * example 1: get_included_files(); // * returns 1: ['http://kevin.vanzonneveld.net/pj_tester.php'] var cur_file = {}; cur_file[this.window.location.href] = 1; if (!this.php_js) { this.php_js = {}; } if (!this.php_js.includes) { this.php_js.includes = cur_file; } var includes = []; var i = 0; for (var key in this.php_js.includes){ includes[i] = key; i++; } return includes; } |
Examples
Running
1 | get_included_files(); |
Should return
1 | ['http://kevin.vanzonneveld.net/pj_tester.php'] |
Dependencies
No dependencies, you can use this function standalone.
Open syntax issues
php.js uses JsLint to help us keep our code consistent and prevent some common bugs.
Eventually we want all code to pass or at least take into consideration most fixes suggested by JsLint, following this JsLint configuration we’ve decided on.
Authors
Thanks to the following developers, you get to have get_included_files goodness in JavaScript.
No comments yet. Be the first!
spread the word:
Use any PHP function in JavaScript
These kind folks have already donated: Anonymous and Shawn Houser.
<your name here>