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

From: Date: Sun, 13 Sep 2015 01:19:52 +0000
Subject: Bug #70479 [Opn->Fbk]: Substr() appends invisible characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195974@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: Open +Status: Feedback 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: Did you save that file using Windows-style line endings, which are \r\n and not \n? Previous Comments: ------------------------------------------------------------------------ [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 (#195974) next »