Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53662 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15900 invoked from network); 29 Jun 2011 15:06:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jun 2011 15:06:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:48705] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/C2-32143-66F3B0E4 for ; Wed, 29 Jun 2011 11:06:14 -0400 Received: by qwi4 with SMTP id 4so726310qwi.29 for ; Wed, 29 Jun 2011 08:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=OwdwPfuZE3wR3b24u5W3f1ppnP+BWrxdulcCTHLsQD0=; b=x1xlvTzyhjHV1UUaDMZcs8GSk4ZA/fxRCcTrAhlvXkQRvsItq9IlBtTD24fM0FC8zi daqlEuWTR1+rrY3DvxxSHtUkLSZXf/n9NvpSWH3lQyZteX+4/4IIjvC2iDglYPpT7kqp 6CdGMHTNRHLZbFTuS0zd3yMfDZirWfGswMX5g= Received: by 10.224.32.169 with SMTP id c41mr553508qad.97.1309359971166; Wed, 29 Jun 2011 08:06:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.215.72 with HTTP; Wed, 29 Jun 2011 08:00:42 -0700 (PDT) Reply-To: RQuadling@GMail.com In-Reply-To: <4E0B3C7B.10102@nouvo.com> References: <4E0B3C7B.10102@nouvo.com> Date: Wed, 29 Jun 2011 16:00:42 +0100 Message-ID: To: Pascal COURTOIS Cc: Internals Mailing List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] unexpected modification of a variable From: rquadling@gmail.com (Richard Quadling) On 29 June 2011 15:53, Pascal COURTOIS wrote: > Hi, > > Is there any way that a variable can be changed within a function without= passing it by reference ? > > I have a code like that: > > function myfunction($var) > { > > =C2=A0 > =C2=A0print_r($var); =3D> prints $var which is an object > =C2=A0anotherfunction($var); =C2=A0// call by value > =C2=A0print_r($var); =3D> $var has changed > > } > > > I thought that since there's no reference in any way to the variable it c= annot be changed in the function. Am I wrong ? For variables ... For objects, $var is always an alias to an object identifier which points to the same object... http://docs.php.net/manual/en/language.oop5.references.php --=20 Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea