|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-12-22 03:08 UTC] laruence@php.net
[2015-12-22 03:08 UTC] laruence@php.net
-Status: Open
+Status: Closed
[2016-07-20 11:34 UTC] davey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 21:00:01 2025 UTC |
Description: ------------ If I try the test script on Windows 10 or (probably) on CentOS, I will get this result: array(3) { [0]=> int(0) [1]=> int(1) [2]=> int(2) } array(3) { [0]=> string(1) "0" [1]=> string(1) "1" [2]=> string(1) "2" } PHP converted all integers in $a array to strings but the original array should stay untouched! But it's even worse on Ubuntu 14.04.3 LTS (PHP Version 7.0.1-2+deb.sury.org~trusty+1) where it returns at first the same result as on the other operating systems but after some page refreshes (press F5 in your browser about 20 times) it returns: array(3) { [0]=> string(1) "0" [1]=> string(875835694) "<br /> <b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 3688507696953442304 bytes) or sometimes: array(3) { [0]=> string(1862275224) "<br /> <b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 140065040769024 bytes) In another script (where I found out there is something wrong with PHP) it didn't throw that fatal error but it modified the $a array like this (original $a array has 10 items): array(10) { [0]=> string(5) "https" [1]=> string(5) "https" [2]=> string(0) "" [3]=> string(5) "15421" [4]=> string(5) "15421" [5]=> string(7) "CGI/1.1" [6]=> string(6) "HTTP/2" [7]=> string(6) "HTTP/2" [8]=> string(5) "close" [9]=> string(1) "0" } If I convert items of $a array to string by hand ($a = ["0", "1", "2"]), everything is working correctly. Test script: --------------- <?php $a = [0, 1, 2]; $b = ["Nula", "Jedna", "Dva"]; var_dump($a); str_replace($a, $b, "1"); var_dump($a); Expected result: ---------------- array(3) { [0]=> int(0) [1]=> int(1) [2]=> int(2) } array(3) { [0]=> int(0) [1]=> int(1) [2]=> int(2) } Actual result: -------------- array(3) { [0]=> int(0) [1]=> int(1) [2]=> int(2) } array(3) { [0]=> string(1) "0" [1]=> string(1) "1" [2]=> string(1) "2" }