|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-06-01 08:29 UTC] 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!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 17:00:01 2025 UTC |
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"); ?>