Bug #68932 [Com]: error in explode with "\e..."

From: Date: Wed, 28 Jan 2015 14:44:17 +0000
Subject: Bug #68932 [Com]: error in explode with "\e..."
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190267@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68932&edit=1 ID: 68932 Comment by: cmbecker69 at gmx dot de Reported by: wborba dot dev at gmail dot com Summary: error in explode with "\e..." Status: Open Type: Bug Package: Scripting Engine problem Operating System: linux/debian PHP Version: 5.5Git-2015-01-28 (Git) Block user comment: N Private report: N New Comment: 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>. Previous Comments: ------------------------------------------------------------------------ [2015-01-28 12:35:16] 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 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68932&edit=1

« previous php.bugs (#190267) next »