note 89514 modified in memcached.callbacks.result by danbrown

From: Date: Thu, 12 Mar 2009 01:55:33 +0000
Subject: note 89514 modified in memcached.callbacks.result by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151752@lists.php.net to get a copy of this message
I was having trouble making method calls with the result callbacks in getDelayed, so I emailed the developer. If you want to use a non-static method as a callback, use the following format: array($obj, 'method'); for example: <?php class foo { private $M = false; public function __construct() { $this->M = new Memcached(); $this->M->addServer('localhost', 11211); $this->M->set('a', 'test'); } public function test() { $this->M->getDelayed(array('a'), false, array($this, 'fun')); } public function fun() { echo "Great Success!"; } } $f = new foo(); $f->test(); ?> or, alternatively: <?php class foo { public $M = false; public function __construct() { $this->M = new Memcached(); $this->M->addServer('localhost', 11211); $this->M->set('a', 'test'); } public function fun() { echo "Great Success!"; } } $f = new foo(); $f->M->getDelayed(array('a'), false, array($f, 'fun')); ?> Works great, thanks Andrei :) --was-- I was having trouble making method calls with the result callbacks in getDelayed, so I emailed the developer. If you want to use a non-static method as a callback, use the following format: array($obj, 'method'); for example: class foo { private $M = false; public function __construct() { $this->M = new Memcached(); $this->M->addServer('localhost', 11211); $this->M->set('a', 'test'); } public function test() { $this->M->getDelayed(array('a'), false, array($this, 'fun')); } public function fun() { echo "Great Success!"; } } $f = new foo(); $f->test(); or, alternatively: class foo { public $M = false; public function __construct() { $this->M = new Memcached(); $this->M->addServer('localhost', 11211); $this->M->set('a', 'test'); } public function fun() { echo "Great Success!"; } } $f = new foo(); $f->M->getDelayed(array('a'), false, array($f, 'fun')); Works great, thanks Andrei :) http://php.net/manual/en/memcached.callbacks.result.php

« previous php.notes (#151752) next »