php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24454 Problems with preg_match() in while(!feof()) loop
Submitted: 2003-07-02 01:48 UTC Modified: 2003-07-02 08:11 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mattias at segerdahl dot info Assigned:
Status: Closed Package: PCRE related
PHP Version: 5.0.0b1 (beta1) OS: Mandrake 9.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mattias at segerdahl dot info
New email:
PHP Version: OS:

 

 [2003-07-02 01:48 UTC] mattias at segerdahl dot info
Description:
------------
When running the following test, php dies on the 2nd loop preg_match()

Reproduce code:
---------------
==[test.php]===========================
<?php
  
  $fp = fopen("dirlist.template.php","r");
  
  while(!feof($fp))
  {
    echo 'start<br>' . "\n";
	echo preg_replace("/\[!([^\]]+)!\]/e","\$this->tpl[\"\\1\"]",fgets($fp,1024));
    echo 'there<br>' . "\n";
  }
  
  fclose($fp);

  show_source("test2.php");
  show_source("dirlist.template.php");
?>
=======================================

==[dirlist.template.php]===============
<tr>
  <td width="20"><img src="templates/images/ico_[!FILETYPE!].gif" width="16" height="16" alt="" border="0"></td>
  <td align="left"><a href="[!FILEURL!]">[!FILENAME!]</a></td>
  <td align="right">[!VERSIONS!]</td>
  <td align="right">[!DATETIME!]</td>
</tr>
=======================================


Expected result:
----------------
start
end
start

Actual result:
--------------
start
end
start
end
start
end
start
end
start
end
start
end

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-02 01:48 UTC] mattias at segerdahl dot info
Expected results and actual results should be switched.
 [2003-07-02 01:57 UTC] mattias at segerdahl dot info
Expected results and actual results should be switched.
 [2003-07-02 08:11 UTC] sniper@php.net
1. Wrong category
2. Bad, very bad example script (uses external resource,dirlist.template.php, which we do not have) 
3. Already fixed in CVS.

 [2003-07-02 08:11 UTC] sniper@php.net
..and I should learn to read. :)

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Nov 12 18:01:32 2019 UTC