gpt4 book ai didi

php - PHP 中的 new MyClass() 与 new MyClass()

转载 作者:可可西里 更新时间:2023-11-01 13:48:07 26 4
gpt4 key购买 nike

以下有区别吗?

$myVar=&new MyClass();
$myVar=new MyClass();

我正在用 PHP 编写代码

最佳答案

如果使用 PHP5,则没有区别。

如果使用 PHP4,前者传递对新对象的引用。

This is because "new" does not return a reference by default, instead it returns a copy.

Source .

Give this a read, too .

关于php - PHP 中的 new MyClass() 与 new MyClass(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8220791/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com