just a curious question...

    Date: 05/12/05 (PHP Community)    Keywords: php

    In PHP 5, say I pass a newly-created array to a function, like this:

    function foo($a) { }
    foo(array("one" => 1, "two" => 2, "three" => 3));

    Does that cause the array to be created, then copied unnecessarily when it's passed to the function, or is PHP smart about it? I know I can do it the following way instead, to ensure that it's not copied:

    function foo(&$a) { }
    $bar = array("one" => 1, "two" => 2, "three" => 3);
    foo($bar);

    But I'm just curious about the first way. Anyone know?

    Source: http://www.livejournal.com/community/php/298532.html

« stupid php 4 || PluggedOut CMS 0.4.9... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home