- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove a function at runtime in PHP?
The functions and classes in PHP have global scope. This means they could be called outside a function even after they were defined inside the scope and the other way round.
But PHP doesn't support function overloading, and it is not possible to redefine previously-declared functions.
The function can be defined as an anonymous function and it can be unset after it completes its run.
Below is a code sample for the same −
if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) $my_fn = create_function('&$v, $k', '$v = stripslashes($v);'); array_walk_recursive(array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST), $my_fn); unset($my_fn); }
An anonymous function can't be called inside itself. The workaround is to use array_walk_recursive.
- How can we define a Python function at runtime?
- How to skip TestNG test at runtime?
- How to change a textView Style at runtime in android?
- How to install and import Python modules at runtime?
- How to get memory usage at runtime using C++?
- How to request Location Permission at runtime on iOS
- How to request Location Permission at runtime on Kotlin?
- How I can check a Python module version at runtime?
- How to load classes at runtime from a folder or Java package
- How to set target and action for UIBarButtonItem at runtime?
- How to retrieve the test suite name at runtime in TestNG?
- How to change a TextView's style at runtime in Android using Kotlin?
- How do I change current theme at runtime in my android app?
- How to determine the size of an Android view at runtime using Kotlin?
- Working with two-dimensional array at runtime in C programming