php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #67701 space in comma separated extensions list in spl_autoload_extensions()
Submitted: 2014-07-28 20:49 UTC Modified: 2019-05-15 11:59 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: fafnir2201 at gmail dot com Assigned: peehaa (profile)
Status: Closed Package: SPL related
PHP Version: 5.5.15 OS: Ubuntu 14.04
Private report: No CVE-ID: None
 [2014-07-28 20:49 UTC] fafnir2201 at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.spl-autoload-extensions
---
I try to register extensions with spl_autoload_extensions(). Extensions list contains space after comma in string i.e. ".php, .class.php". For autoloading I use spl_autoload_register() without parameters. This scheme doesn't work until I'll remove space from extensions list (i.e. ".php,.class.php"). I guess it should be better to trim spaces after separating string with extensions or add notice about this feature to the documentation.

Test script:
---------------
file project/system/test.class.php:
<?php
namespace system;
class test {
public static function alert() {
echo "test";
} } ?>

file project/index.php:
<?php
spl_autoload_extensions('.php, .class.php');
spl_autoload_register();
system\test::alert();
?>

Expected result:
----------------
test

Actual result:
--------------
Fatal error: Uncaught exception 'LogicException' with message 'Class system\test could not be loaded' in /var/www/project/index.php:4 Stack trace: #0 /var/www/project/index.php(4): spl_autoload('system\test') #1 {main} thrown in /var/www/project/index.php on line 4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-18 12:25 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2018-06-18 12:25 UTC] cmb@php.net
Changing to doc problem.  If you prefer to actually change the
behavior of spl_autoload_extensions() in this regard, please
provide a pull request or start a discussion on the internals@
mailing list.
 [2018-06-18 12:25 UTC] cmb@php.net
-Type: Feature/Change Request +Type: Documentation Problem
 [2019-05-15 11:57 UTC] peehaa@php.net
Automatic comment from SVN on behalf of peehaa
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=347422
Log: Added example and a note to make it clear to not use a space character between file extensions in the list. Closes #67701
 [2019-05-15 11:59 UTC] peehaa@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: peehaa
 [2019-05-15 11:59 UTC] peehaa@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-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 13:01:23 2020 UTC