#37662 [NEW]: "Call to undefined function ()" when with strpos("\r")
| From: | mg at evolution515 dot net | Date: | Thu, 01 Jun 2006 08:29:24 +0000 |
| Subject: | #37662 [NEW]: "Call to undefined function ()" when with strpos("\r") | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-97888@lists.php.net to get a copy of this message | ||
From: mg at evolution515 dot net
Operating system: Debian/Sarge
PHP version: 5.1.4
PHP Bug Type: Unknown/Other Function
Bug description: "Call to undefined function ()" when with strpos("\r")
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 bug report at http://bugs.php.net/?id=37662&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37662&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37662&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37662&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37662&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37662&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37662&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37662&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37662&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37662&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37662&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37662&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37662&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37662&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37662&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37662&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37662&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37662&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37662&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37662&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37662&r=mysqlcfg