phpjs
Version:
56 lines (48 loc) • 1.64 kB
Markdown
layout: page
title: "JavaScript runkit_function_remove function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/runkit_function_remove:825
- /functions/view/runkit_function_remove
- /functions/view/825
- /functions/runkit_function_remove:825
- /functions/825
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's runkit_function_remove
{% codeblock runkit/runkit_function_remove.js lang:js https://raw.github.com/kvz/phpjs/master/functions/runkit/runkit_function_remove.js raw on github %}
function runkit_function_remove (funcname) {
// http://kevin.vanzonneveld.net
// + original by: Brett Zamir (http://brett-zamir.me)
// % note 1: Function can only remove from the global context
// * example 1: function add (a, b, c) {return a+b+c;}
// * example 1: runkit_function_remove('add');
// * returns 1: true
if (this.window[funcname] === undefined) { // Requires existing function?
return false;
}
try {
this.window[funcname] = undefined;
} catch (e) {
return false;
}
return true;
}
{% endcodeblock %}
- [view on github](https://github.com/kvz/phpjs/blob/master/functions/runkit/runkit_function_remove.js)
- [edit on github](https://github.com/kvz/phpjs/edit/master/functions/runkit/runkit_function_remove.js)
### Example 1
This code
{% codeblock lang:js example %}
function add (a, b, c) {return a+b+c;}
runkit_function_remove('add');
{% endcodeblock %}
Should return
{% codeblock lang:js returns %}
true
{% endcodeblock %}
### Other PHP functions in the runkit extension
{% render_partial _includes/custom/runkit.html %}