You may be using memcached without ASCII protocol support, for example, if you ran:
$ memcached -B binary
If so, remove the -B argument completely and both PHP and telnet should work.
It is also possible that your memcached was compiled with SASL support, which disabled the ASCII protocol, which PHP requires to connect to memcached.
This explains why it works, but you cannot issue ASCII commands via telnet (or PHP).
You can verify this by doing:
$ memcached -S
You should see this output if memcached was not compiled using SASL: "This server is not built with SASL support."
source share