php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68932 error in explode with "\e..."
Submitted: 2015-01-28 12:35 UTC Modified: 2015-01-28 15:55 UTC
From: wborba dot dev at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.5Git-2015-01-28 (Git) OS: linux/debian
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wborba dot dev at gmail dot com
New email:
PHP Version: OS:

 

 [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
) 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-28 14:44 UTC] cmbecker69 at gmx dot de
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>.
 [2015-01-28 15:55 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 [2015-01-28 15:55 UTC] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 11:00:02 2026 UTC