This file contains hidden or 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 | |
| for (expressao1; expressao2; expressao3) { | |
| //Declarações aqui... | |
| } |
This file contains hidden or 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 | |
| $contador = 0; | |
| for (;;) { | |
| if ($contador == 5) { | |
| break; | |
| } |
This file contains hidden or 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 | |
| for ($contador = 0; $contador < 5; $contador++) { | |
| echo $contador . PHP_EOL; | |
| } | |
| /* | |
| Saída: |
This file contains hidden or 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 | |
| for ($condicao = true, $contador = 1; $condicao;) { | |
| if ($contador > 4) { | |
| $condicao = false; | |
| } | |
| echo ($contador ++) . PHP_EOL; | |
| } |
This file contains hidden or 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 | |
| for ($list = range(1, 5); count($list) > 0;) { | |
| echo array_pop($list) . PHP_EOL; | |
| } | |
| /* | |
| Saída: | |
| 5 | |
| 4 |
This file contains hidden or 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 | |
| class Aluno { | |
| private $codigo; | |
| private $nome; | |
| private $email; | |
| private $telefone; | |
| private $celular; | |
| private $status; | |
| private $instituicao; |
This file contains hidden or 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 | |
| $listFrults = array( | |
| 'p' => 'Pineapple', | |
| 'c' => 'Cashew', | |
| 'a' => 'Apple' | |
| ); | |
| //Essa função lambda somente conta a quantidade de | |
| // caracteres de cada string do Array dado. |
This file contains hidden or 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 | |
| $listFruits = array('Apple', 'Pineapple', 'Pear'); | |
| echo count($listFruits);//Output: 3 |
This file contains hidden or 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 | |
| //Lista de funcionários e seus correspondentes salários: | |
| $listSalary = array( | |
| 'employee_1' => 2100.00, | |
| 'employee_2' => 2500.00, | |
| 'employee_3' => 3000.00, | |
| 'employee_4' => 1300.00, | |
| 'employee_5' => 2100.00, | |
| ); |
This file contains hidden or 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 | |
| //Lista de funcionários e seus correspondentes salários: | |
| $listSalary = array( | |
| 'employee_1' => 2100.00, | |
| 'employee_2' => 2500.00, | |
| 'employee_3' => 3000.00, | |
| 'employee_4' => 1300.00, | |
| 'employee_5' => 2100.00, | |
| ); |