phpjs
Version:
62 lines (54 loc) • 2.05 kB
Markdown
layout: page
title: "JavaScript set_include_path function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/set_include_path:855
- /functions/view/set_include_path
- /functions/view/855
- /functions/set_include_path:855
- /functions/855
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's set_include_path
{% codeblock info/set_include_path.js lang:js https://raw.github.com/kvz/phpjs/master/functions/info/set_include_path.js raw on github %}
function set_include_path (new_include_path) {
// http://kevin.vanzonneveld.net
// + original by: Brett Zamir (http://brett-zamir.me)
// % note 1: Should influence require(), include(), fopen(), file(), readfile() and file_get_contents()
// % note 1: Paths could conceivably allow multiple paths (separated by semicolon and allowing ".", etc.), by
// % note 1: checking first for valid HTTP header at targeted address
// * example 1: set_include_path('/php_js');
// * returns 1: '/old_incl_path'
// BEGIN REDUNDANT
this.php_js = this.php_js || {};
this.php_js.ini = this.php_js.ini || {};
// END REDUNDANT
var old_path = this.php_js.ini.include_path && this.php_js.ini.include_path.local_value;
if (!old_path) {
this.php_js.ini.include_path = {
global_value: new_include_path,
local_value: new_include_path
};
} else {
this.php_js.ini.include_path.global_value = new_include_path;
this.php_js.ini.include_path.local_value = new_include_path;
}
return old_path;
}
{% endcodeblock %}
- [view on github](https://github.com/kvz/phpjs/blob/master/functions/info/set_include_path.js)
- [edit on github](https://github.com/kvz/phpjs/edit/master/functions/info/set_include_path.js)
### Example 1
This code
{% codeblock lang:js example %}
set_include_path('/php_js');
{% endcodeblock %}
Should return
{% codeblock lang:js returns %}
'/old_incl_path'
{% endcodeblock %}
### Other PHP functions in the info extension
{% render_partial _includes/custom/info.html %}