923 B
923 B
title | localeTitle |
---|---|
Functions | Funções |
Introdução às Funções PHP
Uma função é um bloco de instruções que podem ser usadas repetidamente em um programa.
Função Simples + Chamada
function say_hello() {
return "Hello!";
}
echo say_hello();
Função Simples + Parâmetro + Chamada
function say_hello($friend) {
return "Hello " . $friend . "!";
}
echo say_hello('Tommy');
strtoupper - Torna todos os Chars MAIORES E MAIORES!
function makeItBIG($a_lot_of_names) {
foreach($a_lot_of_names as $the_simpsons) {
$BIG[] = strtoupper($the_simpsons);
}
return $BIG;
}
$a_lot_of_names = ['Homer', 'Marge', 'Bart', 'Maggy', 'Lisa'];
var_dump(makeItBIG($a_lot_of_names));