|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-02-28 12:28 UTC] j dot arnold at qaamgo dot com
Description:
------------
When executing the code below with "?lang=de_DE", the first call will result in a float with comma in the concatenated string. On the second call this will result in a float with a dot.
When disabling opcache the issue is gone and it is always a comma.
Also in php 7.3 this issue does not occure.
So it seems that opcache is ignoring the setlocale.
Test script:
---------------
class Test {
function __construct() {
// call https://domain.tld?lang=de_DE
// first call will result in a float with COMMA in the concatenated string
// second call will result in a float with DOT in the concatenated string
if ($_GET['lang']) {
setlocale(LC_ALL, $_GET['lang'] . '.utf-8');
}
$z = 0.5;
$y = $z . ' invalidate cache for this class by changing something here: v1';
echo 'Concatenated string: ' . $y . '<br />';
echo 'Plain Variable: ';
echo $z;
echo '<br />';
exit;
}
}
$test = new Test();
Expected result:
----------------
The float will always be with ",".
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 04:00:02 2025 UTC |
This is due to opcode optimization, in this case OPcache produces: ECHO string("Concatenated string: 0,5 invalidate cache for this class by changing something here: v1<br />") This also potentially happens with PHP 7.3; it depends on opcache.optimization_level. Using opcache.optimization_level=0x7FFEBF7F (i.e. disabling bit 7) makes the code working as expected.