php-memcached-dev / php-memcached

memcached extension based on libmemcached library
Other
990 stars 323 forks source link

Problem stored float value in PHP 8.1/8.2 #538

Closed AndrzejW2016 closed 1 year ago

AndrzejW2016 commented 1 year ago

The following code returns a negative value after entering a float value. What am I doing wrong, is it a problem in the code? Because in PHP 8.0 there is no problem.

$memcached = new Memcached();
$memcached->addServer('memcached.sock', 0, 1);

Class Test {
    public float $value1 = 123.00;
    public float $value2 = 100.00;
    public int $value3 = 2;
}

$test = new Test();
$memcached->set('KEYFLOATSET1', $test->value1, 5);
$memcached->set('KEYFLOATSET2', $test->value2, 5);
$memcached->set('KEYFLOATSET3', $test->value3, 5);
var_dump($memcached->get('KEYFLOATSET1'));
var_dump($memcached->get('KEYFLOATSET2'));
var_dump($memcached->get('KEYFLOATSET3'));
sodabrew commented 1 year ago

Could you share what you learned for future visitors coming in from search?