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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
34 - 24 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 10:01:28 2024 UTC