I would like to create a property which is a class in and of itself and add other methods to it within the "parent" class MyName
, so that I would be able to do something like
$myname = new MyName();
$myname->event->post($params);
I've tried the following, but it doesn't work:
class MyName {
public function __construct() {
$this->event = new stdClass();
$this->event->post = function($params) {
print_r($params);
};
}
}
$x = new MyName();
$x->event->post(array(1, 2, 3));
Which simply ends up flagging the following fatal error:
Fatal error: Call to undefined method stdClass::post() in C:\xampp\htdocs\Arkwayecreation\primepromotions\api\classes\FacebookWrapper.php on line 25