Bug #70479 [Fbk->Nab]: Substr() appends invisible characters

From: Date: Sun, 13 Sep 2015 01:29:23 +0000
Subject: Bug #70479 [Fbk->Nab]: Substr() appends invisible characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195976@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70479&edit=1 ID: 70479 Updated by: requinix@php.net Reported by: nino dot skopac at gmail dot com Summary: Substr() appends invisible characters -Status: Feedback +Status: Not a bug Type: Bug Package: Strings related Operating System: Win 10 x64 (winver=10240) PHP Version: 7.0.0RC2 Block user comment: N Private report: N New Comment: Then there you go. Previous Comments: ------------------------------------------------------------------------ [2015-09-13 01:24:25] nino dot skopac at gmail dot com I made the file out of scratch in Dreamweaver for Windows, so I guess so. ------------------------------------------------------------------------ [2015-09-13 01:19:51] requinix@php.net Did you save that file using Windows-style line endings, which are \r\n and not \n? ------------------------------------------------------------------------ [2015-09-13 01:00:05] nino dot skopac at gmail dot com Description: ------------ When using substr() on v.7 RC2 on my local machine, I am getting different results than when I run the same script on my Linux webserver running v. 5.6.11 Test script: --------------- <?php error_reporting(E_ALL); ob_start(); ?> resources/layout.css resources/jquery.fancybox.css <?php $files = ob_get_clean(); $fs = explode("\n", $files); foreach($fs as $f) { $ext = substr($f, strrpos($f, "."), strlen($f)); $ext_trimmed = trim($ext); var_dump($ext, $ext_trimmed); } ?> Expected result: ---------------- string(4) ".css" string(4) ".css" string(4) ".css" string(4) ".css" bool(false) string(0) "" Actual result: -------------- string(5) ".css" string(4) ".css" string(5) ".css" string(4) ".css" string(0) "" string(0) "" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70479&edit=1

« previous php.bugs (#195976) next »