ID:               49674
 Updated by:       j...@php.net
 Reported By:      lists at reptiliannature dot org
-Status:           Open
+Status:           Bogus
 Bug Type:         SPL related
 Operating System: Linux 2.6.28-15
 PHP Version:      5.3.0
 New Comment:

Class name is lowercased before any lookup is done. Hence, your file 
needs to be in lowercase as well. See also bug #48129


Previous Comments:
------------------------------------------------------------------------

[2009-09-25 19:35:58] lists at reptiliannature dot org

Description:
------------
I have been trying to use spl_autoload() to load a class located in the
same folder. My include path is set to ".".  The class file exists in
the same folder, and the class has the same name as the file without the
.php extension.

The loading does not work. 

Reproduce code:
---------------
File test.php
<?php
set_include_path('.');
var_dump(get_include_path());

$className = 'ClassA';
spl_autoload($className);
$ins = new $className;
echo $ins->val.'<br>';

?>
File ClassA.php
<?php class ClassA { var $val = 'Hello from class "ClassA"'; } ?>

Expected result:
----------------
string(1) "."

Hello from class "ClassA"

Actual result:
--------------
string(1) "."

Fatal error: Uncaught exception 'LogicException' with message 'Class
ClassA could not be loaded' in
/home/michael/src/php/tests/spl_autoload/test.php:7
Stack trace:
#0 /home/michael/src/php/tests/spl_autoload/test.php(7):
spl_autoload('ClassA')
#1 {main}
  thrown in /home/michael/src/php/tests/spl_autoload/test.php on line
7



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49674&edit=1

Reply via email to