Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 PHP 中,使用指针有什么区别,例如:
function foo( $var ) { $var = 3; } $a = 0; foo( &$a );
和参考:
function foo( &$var ) { $var = 3; } $a = 0; foo( $a );
它们都修改了原始变量的值,但是它们在内部的表示方式不同吗?
在 PHP 中,没有指针,只有引用。您的示例演示了通过引用传递
您的代码片段之间的区别仅在于语法,现在不推荐使用第一种语法。
我们正在创建包含大量不规则矩形的交互式 SVG 图表。我们的用户在 SVG 的某个区域内单击,并基于此提供有关该对象的更多信息。(我稍微简化了一点——这是一个工业应用程序,这些区域实际上不是矩形——但我假设我们可以使用每个形状的边界矩形。)
不幸的是