We should keep the value of bcmath.scale and the internal
bc_precision global synchronized.
Probably more important than the ability to retrieve bcmath.scale
via ini_get(), this also makes sure that the set scale does not
leak into the next request, as it currently does.
RETURN_THROWS();
}
- BCG(bc_precision) = (int) new_scale;
+ zend_string *ini_name = zend_string_init("bcmath.scale", sizeof("bcmath.scale") - 1, 0);
+ zend_string *new_scale_str = zend_long_to_str(new_scale);
+ zend_alter_ini_entry(ini_name, new_scale_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
+ zend_string_release(new_scale_str);
+ zend_string_release(ini_name);
}
RETURN_LONG(old_scale);
bcmath.scale=0
--FILE--
<?php
+var_dump((int) ini_get('bcmath.scale'));
var_dump(bcscale(1));
+var_dump((int) ini_get('bcmath.scale'));
var_dump(bcscale(4));
+var_dump((int) ini_get('bcmath.scale'));
var_dump(bcscale());
+var_dump((int) ini_get('bcmath.scale'));
var_dump(bcscale());
?>
--EXPECT--
int(0)
+int(0)
+int(1)
int(1)
int(4)
int(4)
+int(4)
+int(4)