Trapping Errors In PHP?

Langdon langdon at
Mon Apr 24 12:33:31 UTC 2006

I've been employing memcache more and more recently in my code and
occasionally run into problems during development and in live code
where calling $obj->set() causes an error (returns false).

$memcache->connect('localhost', 11211) or
trigger_error('Memcache::Connect failed @ localhost:11211', FATAL);
$memcache->set($memcache_key, $data, true, 86400) or
trigger_error("Memcache::Set failed: $memcache_key", FATAL);

I'll get anywhere from 5-20 error reports in the span of a minute from
the set statement above.

I'm wondering if there exists a better way to capture exact errors? 
Something like a mysql_error() that can tell me what exactly I'm doing
wrong?  I can execute this code 5 times and receive an error... change
$memcache_key and it may or may not resolve.  Sometimes, changing
$data will resolve it as well, but there doesn't seem to be any rhyme
or reason to it.


More information about the memcached mailing list