ID: 37662 Comment by: mg at memedia dot de Reported By: mg at evolution515 dot net Status: Open Bug Type: Unknown/Other Function Operating System: Debian/Sarge PHP Version: 5.1.4 New Comment:
Have you replaced... $lfPos = strpos($this->magicBuffer, "\n"); ....with... $lfPos = strpos($this->magicBuffer, "\r"); ...? Previous Comments: ------------------------------------------------------------------------ [2006-06-01 08:37:36] mg at evolution515 dot net Ok, and strpos() doesn't find any \n on the search string although there are surely \n in there. I've just seen that was another bug. So this bug is surely realted, but please fix that "undefined function ()" in "if ($a || $b)" at last!! ------------------------------------------------------------------------ [2006-06-01 08:36:23] [EMAIL PROTECTED] Works just fine here. ------------------------------------------------------------------------ [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 (([EMAIL PROTECTED]($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