Doc #67701 [Ver->Csd]: space in comma separated extensions list in spl_autoload_extensions()
| From: | peehaa@php.net | Date: | Wed, 15 May 2019 11:59:32 +0000 |
| Subject: | Doc #67701 [Ver->Csd]: space in comma separated extensions list in spl_autoload_extensions() | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16652@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67701&edit=1
ID: 67701
Updated by: peehaa@php.net
Reported by: fafnir2201 at gmail dot com
Summary: space in comma separated extensions list in
spl_autoload_extensions()
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: SPL related
Operating System: Ubuntu 14.04
PHP Version: 5.5.15
-Assigned To:
+Assigned To: peehaa
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2019-05-15 11:57:08] peehaa@php.net
Automatic comment from SVN on behalf of peehaa
Revision: http://svn.php.net/viewvc/?view=revision&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
------------------------------------------------------------------------
[2018-06-18 12:25:29] 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.
------------------------------------------------------------------------
[2014-07-28 20:49:40] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67701&edit=1