PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Use case:
Piece of code in the db. Using a class to get it and eval() it. Problem is that the context wherein the code is eval'd is not the context I won't. The context that should be the scope of the eval'd code is the place that calls the code that extracts the code out of the db.
class A {
private $loader;
public function setLoader(ILoader $loader) {
$this->loader = $loader;
}
public function specialFunction() {
$this->loader->load('somename'); // should have same effect as require_once('somename');
}
}
class DbLoader implements ILoader {
public function load($file) {
// extract code out of DB and eval it;
}
}
class RequireLoader implements ILoader {
public function load($file) {
// require = file_get_contents + eval
}
}
interface ILoader {
public function load($file);
}