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 | |
| $nome = "Padma"; | |
| $sobrenome = "Patil"; | |
| $casa = "Corvinal"; | |
| if ($nome === "Luna" && $sobrenome === "Lovegood" or $casa === "Corvinal") { | |
| // retorna true, pois priorizou o or | |
| } |
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 | |
| $nome = "Padma"; | |
| $sobrenome = "Patil"; | |
| $casa = "Corvinal"; | |
| function checkTemAcesso(string $nome, string $sobrenome, string $case): bool { | |
| if ($nome === "Luna" && $sobrenome === "Lovegood" or $casa === "Corvinal") { | |
| return true; | |
| } |
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 | |
| $nome = "Luna"; | |
| $sobrenome = "Lovegood"; | |
| $casa = "Corvinal"; | |
| function checkTemAcesso(string $nome, string $sobrenome, string $case): bool { | |
| // poderíamos colocar toda essa linha como retorno, | |
| // só para ficar mais claro fiz assim :) | |
| if ($nome === "Luna" && $sobrenome === "Lovegood" or $casa === "Corvinal") { |
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 | |
| $value = 1; | |
| // retorna false, pois as duas expressões são verdadeiras | |
| // value é igual a 1 e value é menor que 2 | |
| if ($value === 1 xor $value < 2) { | |
| // code | |
| } |
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 | |
| $value = 1; | |
| // retorna true, pois o value é igual a 1 e menor que 2 | |
| if ($value === 1 and $value < 2) { | |
| // code | |
| } | |
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 | |
| if ($isValue1 xor $isValue2) { | |
| // code | |
| } |
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 | |
| $arayOne = ['Lorem', 'Ipsum']; | |
| $arayTwo = ['0' => 'Lorem', 1 => 'Ipsum']; | |
| var_dump($arrayOne == $arrayTwo); | |
| // prints bool(true) | |
| var_dump($arrayOne === $arrayTwo); | |
| // prints bool(false) |
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 | |
| $arrayOne = ['a' => 'Hello', 'b' => 'World', 'c' => 'Lorem']; | |
| $arrayTwo = ['c' => 'Ipsum', 'd' => 'Dolor']; | |
| print_r($arrayOne + $arrayTwo); | |
| // prints: | |
| // [ | |
| // 'a' => 'Hello', | |
| // 'b' => 'World', |
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 | |
| echo "Hello " . "world!" // prints: Hello world! | |
| // Additionally, you can use the shorthand operator (.=). | |
| $hello = "Hello "; | |
| $hello .= "world!"; | |
| echo $hello; // prints: Hello world! | |
| // It's the equivalent to: |
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 | |
| $value = 123; | |
| $value += 123; | |
| echo $value; // prints 246 | |
| // Or | |
| $value = "Hello"; | |
| $value .= " world"; | |
| echo $value; // prints "Hello world" |