|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26762 unserialize() produces lowercase classnames
Submitted: 2004-01-01 18:04 UTC Modified: 2004-01-02 06:44 UTC
From: mail at alexanderklein dot de Assigned: helly (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.0.0RC1-dev OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
49 - 28 = ?
Subscribe to this entry?

 [2004-01-01 18:04 UTC] mail at alexanderklein dot de
I use the __autoload($sClass) feature, and the $sClass 
names are always transmitted as is. With upper and
lower characters.

But when i cache a class with serialize and try
to unserialize, the $sClass names are only lowercase.

System 1
    System 	Windows NT 5.1
    Build Date 	Jan 1 2004 16:06:44
    Server API 	CGI/FastCGI
    PHP API 	20031224
    PHP Extension 	20020429
    Zend Extension 	90021012
System 2
    System 	Linux * 2.4.18 #1 SMP i686
    Build Date 	Dec 23 2003 04:48:50
    Server API 	Apache
    Virtual Directory Support 	disabled
    PHP API 	20031103
    PHP Extension 	20020429
    Zend Extension 	90021012


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-01 18:24 UTC] mail at alexanderklein dot de
A short sample script


function __autoload($sClass) {
    echo $sClass."<br>";


class myTestWithUpper {
    public $test;
    protected function __sleep() {
        return array('test');

        new myTestWithUpper()


    file_get_contents ("./test.dat")
 [2004-01-01 19:42 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

In php class names are not case sensitive and are stored in 
lowercase form internally. 
 [2004-01-01 20:21 UTC] mail at alexanderklein dot de
Ok, you say

> In php class names are not case sensitive and are 
> stored in lowercase form internally. 

but why does the __autoload() function not convert to 
lowercase if i make an instance like "new myTestWithUpper"?

this is a _little_ bit confusing :-(
 [2004-01-01 21:25 UTC]
Behavior is correct as you can see below:

marcus@zaphod /usr/src/php5 $ php -r 'class FOO{}$o=new FOO;var_dump(serialize($o));'
string(14) "O:3:"FOO":0:{}"

marcus@zaphod /usr/src/php5 $ php -r '$o=unserialize("O:3:\"FOO\":0:{}");var_dump($o);'
object(__PHP_Incomplete_Class)#1 (1) {
  string(3) "foo"

marcus@zaphod /usr/src/php5 $ php -r 'class FOO{}$o=unserialize("O:3:\"FOO\":0:{}");var_dump($o);'
object(FOO)#1 (0) {
 [2004-01-01 22:19 UTC]
Actually unserialized lowercases the classname. But we store the lowercased classname only in the hashtable while we preserver the casing for its real name.
 [2004-01-01 22:24 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Feb 07 02:05:48 2023 UTC