php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36731 memory limit exceed by str_replace??
Submitted: 2006-03-14 01:21 UTC Modified: 2006-03-14 09:34 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: prezident at terix dot ru Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.1.2 OS: ???
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: prezident at terix dot ru
New email:
PHP Version: OS:

 

 [2006-03-14 01:21 UTC] prezident at terix dot ru
Description:
------------
When i make str_replace on foreach server gives me error #500

Reproduce code:
---------------
	function bhldr($parser, $name, $att) {
			$this->depth++;
		if ($this->snipplets[$name]) {
			$this->mode[$this->depth] = $name;
			return '';
		}
		if ($this->inlines[$name]) {
			$inl = $this->inlines[$name];
			foreach ($att as $key=>$val) {
				$inl = str_replace('#'.$key.'#', $val, $inl);
			}
			$this->result .= $inl;
			return '';
		}
		$this->result .= str_repeat("\t", $this->depth)."<$name";
		foreach ($att as $key=>$val) $this->result .= " $key='$val'";
		$this->result .= ">\r\n";
	}

Expected result:
----------------
parsed xml with tags, listed on array $this->inlines as keys, replaced with values of $this->inlines. Additionally, in the values constructions like "#WIDTH#" must be replaced with $att[] values (i.e., #WIDTH# to $att["WIDTH"]). 

Function bhldr is xml_begin_element_handler.

Actual result:
--------------
Memory issue. My hoster gives max 10MB of RAM for PHP5 (started as CGI).

here error message from Apache error log:

Mar 14 02:59:17 2006] [error] [client #.#.#.#] Premature end of script headers: /usr/local/php5-cgi/domain/php

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-14 01:27 UTC] prezident at terix dot ru
error handles in 10th line of listed code (when its commented, all is good)
 [2006-03-14 08:24 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2006-03-14 09:28 UTC] prezident at terix dot ru
You think so?

So please tell me, why this problem is actual on WinXp under 
PHP Version 5.0.4? My bag? Array $att gives me xml_parser and this error message handles when i just trying to read last value from this array ($x = $att[count($att)-1];)

$att = Array('LOOP'=>'$mods->menu->sublist()', 'ITEM'=>'$menu_item'); 

 Ill try many another ways, but problem is still actual. 
I don't need support from You, i need good php ;)

ssory for my english ))
 [2006-03-14 09:34 UTC] tony2001@php.net
Please ask support questions in more appropriate places.
If your script eats all the memory available it's clearly not PHP problem, but a problem of your code.
And btw, your reproduce code doesn't add any value to the report, since this is just a part of a script and the problem cannot be reproduced with this code.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 10:01:28 2024 UTC