I have a large chunk of legacy php code that I need to interface with that looks like this:
//legacy.php
function foo() {
}
function bar() {
}
I want to be able to wrap these legacy functions in a class or somehow require_once without polluting that global namespace or altering the original file.
You can use a namespace or static methods in a class:
Both would require slight modifications to the file. e.g., Calls to
bar()would have to be changed toFoo::bar()with the above example (class with static methods).OR, using a namespace:
In your file: