Edit report at http://bugs.php.net/bug.php?id=53374&edit=1
ID: 53374
User updated by: pascalholscher at gmail dot com
Reported by: pascalholscher at gmail dot com
Summary: str_replace & fwrite
Status: Bogus
Type: Bug
Package: *General Issues
Operating System: Windows
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
That doesn't work like I want I will show you what I mean:
$newversion = '3.3.5';
define(VERSION, "3.3.4"); // this is the line in the included version
file
$filename = $docroot.'/product_version.php';
if(!$openfile = fopen($filename, 'rb')) {
echo 'Kan bestand niet openen.';
}
$data = file_get_contents($filename);
$version = explode('.', VERSION);
$new = explode('.', $newversion);
$data1 = preg_replace($version[2], $new[2], $data);
fwrite($openfile,$data1);
fclose($openfile);
// my expected result of data1 = making the 3.3.4 in version.php to
3.3.5 the new version but what happends is it replaces the file number
what I want but it doesn't show the echo's on my screen like I want. And
when I quote this function then the echo's are showing on screen.
Previous Comments:
------------------------------------------------------------------------
[2010-11-23 10:54:11] [email protected]
Preg expressions start and end with a delimiter. Using { and } have
special
meanings there. The correct regex you want looks like this:
$data1 = preg_replace('/\{'.$version[2].'\}/', '{'.$new[2].'}', $data);
No bug here.
------------------------------------------------------------------------
[2010-11-23 10:38:28] pascalholscher at gmail dot com
Yes this is happening with php 5 also but it's not a bug it seems as:
$version = explode('.', VERSION);
$new = explode('.', $newversion);
$data1 = preg_replace('{'.$version[2].'}', '.$new[2].', $data);
$version[2] represents the old version number ending in this example a
4
$new[2] represents the new version in this example 5
The thing is when I run it the changes are made but all php errors are
not displayed on the screen anymore same goes for the echo's etc.
Once I make the line like this:
$data1 = preg_replace('{'.$version[2].'}', '{'.$new[2].'}', $data);
It works but only adds some unnesecary and not planned {} to it.
------------------------------------------------------------------------
[2010-11-23 10:27:23] [email protected]
It might seem like a bug to you (and it may be one), but I think there
are a few reasons why you'd be better off going through a support
channel first:
Firstly, you yourself closed the bug report with the comment "Solved",
so that would suggest that there wasn't a bug for us to look at. :)
Secondly, PHP 4 is well past its end of life date, so unless you can
reproduce this in a current 5.3 build (5.3.3 or later), this isn't
going to be investigated further.
Thirdly, you haven't attached a minimal example -- there's quite a bit
of extra code there that doesn't appear to be relevant to the bug --
nor have you explained how the code you've attached is misbehaving,
what error messages are displayed, and it's quite unclear to me what
the actual bug is supposed to be, beyond some sort of issue with
str_replace and/or fwrite, which could be anything.
For those reasons, I'd very strongly advise you to try seeking help
via a mailing list, or Stack Overflow, or IRC, or some combination of
the above. If, after all that, there still seems to be a bug, please
provide a minimal test case showing the problem and a clear
explanation of exactly what's wrong.
------------------------------------------------------------------------
[2010-11-23 08:53:26] pascalholscher at gmail dot com
What do I need to contact to get this fixed.
It seems like a bug to me...
------------------------------------------------------------------------
[2010-11-22 10:37:02] [email protected]
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.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=53374
--
Edit this bug report at http://bugs.php.net/bug.php?id=53374&edit=1