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 | |
echo 'dia 1'; | |
if(1 > 2) { | |
echo 'maior'; | |
} else { | |
echo 'menor'; | |
} |
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 | |
echo "Hello world"; | |
// ... mais código | |
echo "última instrução"; | |
// o script termina aqui, sem tag de fechamento 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
; short_open_tag | |
; Default Value: On | |
; Development Value: Off | |
; Production Value: Off |
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
//comentários de uma linha | |
/* | |
bloco de comentários | |
xxxxxxxxxxxxxxxxxxxx | |
xxxxxxxxxxxxxxxxxxxx | |
*/ |
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 | |
$a = 3 * 3 % 5; // (3 * 3) % 5 = 4 | |
$a = 2 - 2 * 6 + 4; // 2 - (2 * 6) + 4 = 2 - 12 + 4 = -10 + 4 = -6 | |
$a = 1; | |
$b = 2; | |
$a = $b += 3; // $a = ($b += 3) -> $a = 5, $b = 5 |
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 | |
/* | |
* estamos dividindo 4 por 2 uma vez | |
* 4 / 2 == 2 | |
*/ | |
echo 4>>1; | |
echo "<br>"; |
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 | |
/* | |
* $a é igual a 9 agora e $b foi definido como 4. | |
*/ | |
$a = ($b = 4) + 5; | |
/* | |
* atribuição da chave 'nome' ao valor 'PHP7.1', |
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
SHORT FORM O MESMO QUE | |
$a += $b $a = $a + $b //adição | |
$a -= $b $a = $a - $b //subtração | |
$a *= $b $a = $a * $b //multiplicação | |
$a /= $b $a = $a / $b //divisão | |
$a %= $b $a = $a % $b //módulo | |
$a .= $b $a = $a . $b //concatenação |
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 | |
echo "<h3>Pós-incremento</h3>"; | |
$a = 5; | |
echo "Deve ser 5: " . $a++ . "<br>\n"; | |
echo "Deve ser 6: " . $a . "<br>\n"; | |
echo "<h3>Pré-incremento</h3>"; | |
$a = 5; | |
echo "Deve ser 6: " . ++$a . "<br>\n"; |
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 | |
// considere os valores a esquerda sendo $a e os valores a direita $b | |
echo 1 == 1; | |
echo 1 != 2; | |
echo 1 <> 2; | |
echo 1 === 1; | |
echo 1 !== 2; | |
echo 2 > 1; |
OlderNewer