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

From: Date: Thu, 01 Jun 2006 09:23:38 +0000
Subject: #37662 [Opn]: "Call to undefined function ()" when with strpos("\r")
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97904@lists.php.net to get a copy of this message
ID: 37662 User updated by: mg at evolution515 dot net 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: And copy /usr/share/misc/magic to your working dir so the script find a file! (Otherweise the script won't exit in with PHPCLI) Previous Comments: ------------------------------------------------------------------------ [2006-06-01 09:20:57] mg at evolution515 dot net Ok, changed to PHP/5.1.4-1.dotdeb.1. Still the error. CLI as libapache2 produce the same error. $ php BUG.php 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 OK COPY AND PASTE FOLLWING SCRIPT AND TRY AGAIN! -------------------------------------------------- <?php 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, "\r"); // 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"); ?> ------------------------------------------------------------------------ [2006-06-01 08:54:06] derick@php.net Bug update collision, setting back to bogus. ------------------------------------------------------------------------ [2006-06-01 08:47:33] derick@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2006-06-01 08:42:38] tony2001@php.net # php /tmp/2.php strpos() has been successfuly run! I'm sure you don't need a class to check if strpos() finds '\r' or '\n' in strings. ------------------------------------------------------------------------ [2006-06-01 08:38:52] mg at memedia dot de Have you replaced... $lfPos = strpos($this->magicBuffer, "\n"); ....with... $lfPos = strpos($this->magicBuffer, "\r"); ...? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/37662 -- Edit this bug report at http://bugs.php.net/?id=37662&edit=1

« previous php.bugs (#97904) next »