Does PHP also perform shallow copy-on-write for values passed as
parameters to functions?

<?php
  $text = "<...shakespeare...>";

  function blah( $copy )
  {
    echo $copy;
  }

  blah( $text );
?>

Some of the guys I work with like to use: function( &$copy ) in order to
save the hypothetical storage space required to duplicate $text into
$copy, but from earlier discussion, blah() might not get a full copy of
$text unless the function body was: $copy .= '!';, thus making two copies
of $text.

It's almost time for me to start downloading the source tarballs and
answering these questions myself. ;^) Thanks again for all your patience.

--Robert


On Fri, 25 Jan 2002 15:48:54 -0600, Christian Dickmann wrote:
> "Andi Gutmans" <[EMAIL PROTECTED]> wrote
>> PHP 5 per-class constants can already except static arrays such as
>> array(1, 2, 3) as their value. I'll put the issue of global constants
>> on my TODO and believe PHP 5 will also support these for global
>> constants. However, you won't be able to create a constant with a
>> non-constant value such as $_GET as this goes against the whole idea of
>> constant :)
> 
> This is not true to my mind.
> define ("INC_DIR",$foo);
> this "Constant" is not predefined by the developer, BUT it is a
> constant-value for the rest of the script. To my mind such "constants"
> make sense, because
> - they are global
> - they can't change their value while execution - it doesn't matter if
> the constant-value is set dynamically when defining it So I would be
> glad to see this feature in PHP5.

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to