Jump to content

Class variables as functions


Nove

Recommended Posts

Here's a mockup I've tried to be able to set functions of a class when the object is constructed.  I'm not really sure how to go about this, but from what I've made you should get the idea that I want to set f and g to functions.  How can I do this?

[code]function clarence() {
echo "clarence!";
}

function marla() {
echo "marla!";
}

class functioner {
function __construct(&$v, &$b) {
$this->f = $v();
$this->g = $b();
}


}

$c = new functioner(clarence, marla);
$c->t = "5";
echo $c->t;
$c->f();
$c->g();
[/code]
Link to comment
https://forums.phpfreaks.com/topic/20918-class-variables-as-functions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.