martes, 3 de marzo de 2015

PHP Assignment by Reference

Assignment by Reference

Assignment by reference is also supported, using the "$var = &$othervar;" syntax. Assignment by reference means that both variables end up pointing at the same data, and nothing is copied anywhere.
Example #1 Assigning by reference
<?php
$a 
3;$b = &$a// $b is a reference to $a
print "$a\n"// prints 3print "$b\n"// prints 3
$a 4// change $a
print "$a\n"// prints 4print "$b\n"// prints 4 as well, since $b is a reference to $a, which has
              // been changed
?>
 
 
Esto es comoa acceso directo a  una variable 

No hay comentarios:

Publicar un comentario