<?php
//1-global
//2-referencial
//3-return
function trocaValoresComGlobal($a, $b) {
global $a;
global $b;
$seguraValor = $a;
$a = $b;
$b = $seguraValor;
}
//recebe valores input
$a = (int) trim(fgets(STDIN));
$b = (int) trim(fgets(STDIN));
trocaValoresComGlobal($a, $b);
//imprime valores trocados
echo "Os valores trocados são: 1° = $a, 2° = $b\n";
?>
To embed this project on your website, copy the following code and paste it into your website's HTML: