小编Pie*_*tte的帖子

如何替换已弃用的动态属性?

我\xe2\x80\x99m 在 PHP 8.2\xe2\x80\x99s 动态属性弃用方面遇到了困难。I\xe2\x80\x99m 在这里寻找与 PHP 9.0 兼容的永久解决方案,因此添加属性#[AllowDynamicProperties]对我来说不是一个解决方案。

\n

这里\xe2\x80\x99是我的问题。例如,我曾经有以下课程:

\n
class planet {\n    function __construct($id, $a, $m, $i, $e, $\xcf\x80) {\n        $this->a = $a;\n        $this->e = $e;\n        $this->i = $i;\n        $this->id = $id;\n        $this->m = $m;\n        $this->n = .9856076686 / ($a * sqrt($a));\n        $this->\xcf\x80 = $\xcf\x80;\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

然后我将使用以下数组创建每个行星:

\n
$pl = [\n    new planet("Mercury", .38709831, 3.3011e23, 7.004986, .20563, 77.456119),\n    new planet("Venus", .723332982, 4.8675e24, 3.394662, .006772, 131.563703)\n];\n
Run Code Online (Sandbox Code Playgroud)\n

等等。

\n

如果我现在尝试这个,我当然会收到现在著名的通知:\nDeprecated: Creation of …

php php-8.2

1
推荐指数
1
解决办法
2696
查看次数

标签 统计

php ×1

php-8.2 ×1