Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53688 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8708 invoked from network); 29 Jun 2011 22:20:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jun 2011 22:20:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=keisial@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=keisial@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: keisial@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:59755] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/F5-10518-F05AB0E4 for ; Wed, 29 Jun 2011 18:20:00 -0400 Received: by wyf22 with SMTP id 22so1328547wyf.29 for ; Wed, 29 Jun 2011 15:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=AiUIhwApfvPZhqUzDiNRaDU31aRfECqgnheBXrl8dRM=; b=n1/n+lVLsxtAPKdyioL2A21o/Hvx9bFaVOCUOvikzCDT6f1BQeNSxOArDC+Sv/Awwe 9zQo0w4DZmhayMq1sBF13148OxxvyDwpwOExy67sdZGCRqvOUfHgweATjglnptAp5Sip Jmn9ilPbpzRYbppHI7mm8vsY/CwFop0sC3mbg= Received: by 10.227.155.78 with SMTP id r14mr1137728wbw.100.1309385996795; Wed, 29 Jun 2011 15:19:56 -0700 (PDT) Received: from [192.168.1.26] (157.Red-83-35-126.dynamicIP.rima-tde.net [83.35.126.157]) by mx.google.com with ESMTPS id ex2sm1200611wbb.65.2011.06.29.15.19.54 (version=SSLv3 cipher=OTHER); Wed, 29 Jun 2011 15:19:55 -0700 (PDT) Message-ID: <4E0BA642.9010103@gmail.com> Date: Thu, 30 Jun 2011 00:25:06 +0200 User-Agent: Thunderbird MIME-Version: 1.0 To: Pascal COURTOIS , PHP Developers Mailing List References: <4E0B3C7B.10102@nouvo.com> In-Reply-To: <4E0B3C7B.10102@nouvo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] unexpected modification of a variable From: keisial@gmail.com ("=?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?=") 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) > { > > > print_r($var); => prints $var which is an object > anotherfunction($var); // call by value > print_r($var); => $var has changed > > } > > > I thought that since there's no reference in any way to the variable it cannot be changed in the function. Am I wrong ? Maybe the prototype of anotherfunction() receives it by reference. Another option would be that sets some global as a reference to $var, and $var is changed through it. If you have such problem, you should provide a test case. But it's probably a bug in your code that will get solved when piecing it.