Re: What does &var mean ?
| From: | Girish Nath | Date: | Thu, 22 Nov 2001 16:36:39 +0000 |
| Subject: | Re: What does &var mean ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-75521@lists.php.net to get a copy of this message | ||
Thanks, you guys rock! :)
Girish
----- Original Message -----
From: "Roberto Ramírez" <al778510@mail.mty.itesm.mx>
To: "Girish Nath" <girishn@btinternet.com>
Sent: Thursday, November 22, 2001 4:10 PM
Subject: RE: [PHP] What does &var mean ?
The use of the & means that its passed by reference.
That its equal to the memory address of where the variable is stored
&$variable
its often used to modify the value of a that variable within a function.
for example:
<?php
$variable = 3;
echo $variable;
#will print 3
function checkit(&$x){
$x = 5;
#this will modify the value of $variable.
}
checkit($variable);
echo $variable;
#will print 5
?>
________________________________________________
PROSSES, Roberto Ramírez.
Tel-Fax. 8115 3197 y 99
Puerto No. 3425 Col. Riberas del Río CP. 67160 Guadalupe, Nuevo León.
México.
Visítanos aquí: http://www.prosses.com
<http://www.prosses.com> Correo electrónico:
roberto@prosses.com
<mailto:roberto@prosses.com>
-----Mensaje original-----
De: Girish Nath [mailto:girishn@btinternet.com]
Enviado el: Jueves, 22 de Noviembre de 2001 09:43 a.m.
Para: php-general@lists.php.net
Asunto: [PHP] What does &var mean ?
Hi
I've been looking at some classes an have come across this notation for
example :
function remove(&$productid) {
/* this function will remove a given product from the cart */
if (isset($productid)) {
unset($this->items[$productid]);
}
}
What does the "&" (ampersand) before the variable name mean ?
Thanks
Girish
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net