【问题标题】:Is important the size of what I pass to the function?我传递给函数的大小重要吗?
【发布时间】:2015-12-15 13:21:28
【问题描述】:

我想知道,我应该尝试将一个小值传递给函数吗?还是没关系?

例如:

$sth->execute();
function myfunc ($sth){ // do something}

或者

$sth->execute();
$end = $sth->fetch()
function myfunc ($end){ // do something}

哪个更好?

【问题讨论】:

    标签: php performance function parameter-passing


    【解决方案1】:

    没关系。函数调用的性能不依赖于参数的大小。值在内部处理,因此它们基本上总是通过某种或另一种引用传递。在将值传递给函数时,PHP 不会复制该值(是的,即使它可能在用户空间中表现这种方式)。

    【讨论】:

    • 啊,我明白了,谢谢。 +1
    猜你喜欢
    • 1970-01-01
    • 2015-04-24
    • 2014-10-27
    • 2012-09-15
    • 1970-01-01
    • 2015-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多