Is it possible to implement functions as object instances in PHP? I'm used to doing this in Java with the code below, but I can't seem to find a similar approach in PHP. Is it possible?
interface OneVarFunction {
public int eval(int x);
}
static void routine() {
OneVarFunction func1 = new OneVarFunction() {
public Boolean eval(int x) {
return x*x;
}
};
OneVarFunction func2 = new OneVarFunction() {
public Boolean eval(int x) {
return 2*x+1;
}
};
}