#37662 [Opn->Fbk]: "Call to undefined function ()" when with strpos("\r")

From: Date: Thu, 01 Jun 2006 08:36:23 +0000
Subject: #37662 [Opn->Fbk]: "Call to undefined function ()" when with strpos("\r")
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97889@lists.php.net to get a copy of this message
ID: 37662 Updated by: tony2001@php.net Reported By: mg at evolution515 dot net -Status: Open +Status: Feedback Bug Type: Unknown/Other Function Operating System: Debian/Sarge PHP Version: 5.1.4 New Comment: Works just fine here. Previous Comments: ------------------------------------------------------------------------ [2006-06-01 08:29:24] mg at evolution515 dot net Description: ------------ Search for the comment "try changing this value!" und try one run with "\r" (BAD!) and then another with "\n" or "\t" (BOTH GOOD). RESULT: While the first run of strpos() is successful, the other one in the while-loop results in an error! OUTPUT: strpos() has been successfuly run Fatal error: Call to undefined function () in /home/www/Projekte/flyerpilot.de/htdocs.dev/MimeMagic/BUG.php on line 41 NOTE: I encounter often errors especially in sentences like "if ($a ||$b) " that results in the same error. The only workaround I found so far is"if ($a+$b>0)" that usualy works good. Do you know about this error? I couldn't find any related ticket. And I really get it for some PHP versions back. Oh yeah.. i was to lazy to recompile, but i guess that error will still exist in 5.1.4 as it did since 5.0 or before. PHP Version 5.1.2-Debian-0.1~sarge1 (Debian GNU/Linux) Reproduce code: --------------- <?php // User your linux /usr/share/misc/magic for the magic-file! class MagicReader { private $magicBuffer = ''; private $magicFile; private $fp; function __construct($filename=null) { if (is_string($filename)) $this->openMagicFile($filename); $this->convert(); $this->closeMagicFile(); } function openMagicFile($filename) { $this->magicFile = @fopen($filename, 'r'); return $this->magicFile; } function closeMagicFile() { return @fclose($this->magicFile); } function convert() { while ($line = $this->readLine()) { echo $line; die(); } } private function readLine() { while ((!@feof($this->magicFile)) || (strlen($this->magicBuffer)>0)) { $lfPos = strpos($this->magicBuffer, "\n"); // cahnge this value to R! if ($lfPos !==false) { $this->magicBuffer = substr($this->magicBuffer, $lfPos); return substr($this->magicBuffer, $lfPos)."|"; } $this->magicBuffer = @fread($this->magicFile, 4096); } // if we reached this position we are at the end of the file! $out = $this->magicBuffer; // assign return output if (empty($this->magicBuffer)) {// if buffer is already empty we are really at the end return false; } $this->magicBuffer = ''; // clear out buffer return $out; } function __destruct() { $this->closeMagicFile(); } } $str = "That's a\rlittle Test!"; echo (strpos($str, "\r")) ? "strpos() has been successfuly run!" : "nothing found but successfuly run!"; $reader = new MagicReader("magic"); ?> Expected result: ---------------- No error message. Actual result: -------------- Simple enough. Check out the source! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37662&edit=1

« previous php.bugs (#97889) next »