Created
August 7, 2019 23:25
-
-
Save parzibyte/69dfe6c4955150a781713ab872a9e555 to your computer and use it in GitHub Desktop.
Llamada por referencia en PHP - https://parzibyte.me/blog/2018/09/21/funciones-por-referencia-en-php/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Notar que ponemos el operador | |
& antes del nombre del argumento | |
*/ | |
function incrementar(&$numero){ | |
$numero = $numero + 1; | |
} | |
$numero = 10; | |
echo "El número es $numero\n"; | |
/* | |
Aquí pasamos el argumento como lo haríamos con | |
cualquier función, sin usar & ni nada de esas | |
cosas | |
*/ | |
incrementar($numero); | |
echo "El número es $numero\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment