php中的函数
openssl_free_key
已被弃用,并且不包含在PHP 8中。谁能给出一个替代方案?
这个函数现在已被弃用,因为它不再有效果了。
https://www.php.net/manual/en/function.openssl-free-key.php
PHP 8不支持openssl_free_key(实际上是它的别名openssl_pkey_free),并且在超出作用域时自动销毁密钥实例。
https://www.php.net/manual/en/function.openssl-pkey-free.php # 125655
所以实际上你不用任何东西替换它,因为资源现在被正确地清理了,就像其他任何东西一样。
如果你想感觉你在做额外的事情,你可以调用unset()
,但我认为这不是必要的。
如果您需要与旧的php版本保持兼容性,您可以这样做:
// $privateKey = openssl_pkey_new([ ... ]);
if (PHP_VERSION_ID < 80000) {
openssl_free_key($privateKey);
}