note 76548 added to language.functions

From: Date: Fri, 20 Jul 2007 01:32:49 +0000
Subject: note 76548 added to language.functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-128750@lists.php.net to get a copy of this message
deek at none dot net, The explanation of why your example does what it does is not quite right. function ChangeString(&$SuplyedString) { $SuplyedString = "BBB"; }; ChangeString($AAA='AAA'); print $AAA; exit; The assignment does, in fact, get executed before the function call. The reason that this prints 'AAA' is because '=' is an operator that returns the value that it assigned. In this case, the value 'AAA' is assigned to the variable $AAA, and the assignment expression returns a value of 'AAA'. It is this returned value that gets passed as an argument to the function, and this returned value is unconnected to the variable $AAA. $AAA = 'AAA'; ChangeString($AAA); print $AAA; exit; In this case, a reference to the variable is being passed. Hope this helps... ---- Server IP: 69.147.83.197 Probable Submitter: 216.98.102.225 ---- Manual Page -- http://www.php.net/manual/en/language.functions.php Edit -- https://master.php.net/note/edit/76548 Del: integrated -- https://master.php.net/note/delete/76548/integrated Del: useless -- https://master.php.net/note/delete/76548/useless Del: bad code -- https://master.php.net/note/delete/76548/bad+code Del: spam -- https://master.php.net/note/delete/76548/spam Del: non-english -- https://master.php.net/note/delete/76548/non-english Del: in docs -- https://master.php.net/note/delete/76548/in+docs Del: other reasons-- https://master.php.net/note/delete/76548 Reject -- https://master.php.net/note/reject/76548 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128750) next »