|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-01-28 12:35 UTC] wborba dot dev at gmail dot com
Description:
------------
is simple, the code below works in version < 5.5, but version >= 5.5 does not work.
$arr = array("controller" => "IDoc\Home\ecommerce","request_method" => "POST");
$x = $arr["controller"];
$y = explode("\\",$x);
print_r($y);
the result correct is...
Array
(
[0] => IDoc
[1] => Home
[2] => ecommerce
)
but in php >= 5.5 is wrong...
Array
(
[0] => IDoc
[1] => Homecommerce
)
Test script:
---------------
$arr = array("controller" => "IDoc\Home\ecommerce","request_method" => "POST");
$x = $arr["controller"];
$y = explode("\\",$x);
print_r($y);
Expected result:
----------------
Array
(
[0] => IDoc
[1] => Home
[2] => ecommerce
)
Actual result:
--------------
Array
(
[0] => IDoc
[1] => Homecommerce
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 11:00:02 2026 UTC |
This is not a bug in PHP, but rather a bug in your code, because you have unescaped backslashes in a string literal. You should always escape backslashes with a backslash: $arr = array( "controller" => "IDoc\\Home\\ecommerce", "request_method" => "POST" ); Anyhow, the code worked in PHP < 5.4.4, because neither \H nor \e were valid escape sequences, but since PHP 5.4.4 \e is a valid escape sequence for ESC. See also the PHP manual page "Strings": <http://php.net/manual/en/language.types.string.php>.