php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54658 The return type of Memcache:pconnect is NOT boolean!
Submitted: 2011-05-04 14:17 UTC Modified: 2011-07-02 04:05 UTC
From: eu at serbannistor dot ro Assigned: frozenfire (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2.17 OS: RH5
Private report: No CVE-ID: None
 [2011-05-04 14:17 UTC] eu at serbannistor dot ro
Description:
------------
---
From manual page: http://www.php.net/memcache.pconnect#Return Values
---

In fact, Memcache::pconnect(), just like Memcache::connect() returns a mixed type.
It will return a Memcache object if the connection is successful or a boolean false if the connection fails. Also a notice and an error will be outputted.

Test script:
---------------
<?php

// memcached is running
$memcache_obj1 = memcache_pconnect("memcache_host1", 11211);
var_dump($memcache_obj1);

/*
will output:
object(Memcache)#3 (1) {
  ["connection"]=>
  resource(6) of type (memcache connection)
}
*/

// memcached is stopped
$memcache_obj2 = memcache_pconnect("memcache_host2", 11211);
var_dump($memcache_obj2);


/*
will output:
PHP Notice:  memcache_pconnect(): Server memcache_host2 (tcp 11211) failed with: Connection refused (111) in /home/jdoe/memcache-test.php on line 31

Notice: memcache_pconnect(): Server memcache_host2 (tcp 11211) failed with: Connection refused (111) in /home/jdoe/memcache-test.php on line 31
PHP Warning:  memcache_pconnect(): Can't connect to memcache_host2:11211, Connection refused (111) in /home/jdoe/memcache-test.php on line 31

Warning: memcache_pconnect(): Can't connect to memcache_host2:11211, Connection refused (111) in /home/jdoe/memcache-test.php on line 31
bool(false)
*/

Expected result:
----------------
According to the documentation the output for the above cases should be:

bool(true);
bool(false);

Actual result:
--------------
Stated above in the description.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-02 04:05 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=312801
Log: Fixed Memcache::pconnect return value, closing bug #54658
 [2011-07-02 04:05 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 [2011-07-02 04:05 UTC] frozenfire@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 16:00:01 2026 UTC