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 | |
$dec = 40; // decimale | |
$oct = 0321; // ottale | |
$hex = 0xBC; // esadecimale | |
$bin = 0b11111; // binario | |
$neg = -125; | |
echo $dec."\n"; // 40 | |
echo $oct."\n"; // 209 | |
echo $hex."\n"; // 188 |
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 | |
$float = 123.30; | |
$float2 = 120e-3; // Sintassi con esponente | |
echo $float."\n"; | |
echo $float2; | |
/* | |
Output |
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 | |
$car = "Ferrari"; | |
$model = 'F40'; | |
echo "Auto $car \n"; | |
echo "Modello $model\n"; | |
/* | |
Output |
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 | |
$lastName = "Biscaldi"; | |
echo $lastName[0]; | |
echo $lastName[3]; | |
echo $lastName[4]; | |
// Output Bca |
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 | |
$string = "Ciao mondo!"; | |
echo strlen($string)."\n"; // Output 11 | |
echo strpos($string, 'mondo')."\n"; // Output 5 | |
echo substr($string, 5, 5)."\n"; // Output mondo | |
echo str_replace('mondo', 'a tutti', $string)."\n"; // Output Ciao a tutti |
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 | |
$x = 30; | |
echo $x."\n"; // Output: 30 | |
$x += 30; | |
echo $x."\n"; // Output: 60 | |
$x -= 20; | |
echo $x."\n"; // Output: 40 |
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 | |
$x = 9; | |
$y = 2; | |
echo $x + $y; // 0utput: 11 | |
echo $x - $y; // 0utput: 7 | |
echo $x * $y; // 0utput: 18 | |
echo $x / $y; // 0utput: 4.5 | |
echo $x % $y; // 0utput: 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
<?php | |
$x = 10; | |
$y = "10"; | |
var_dump($x == $y); // Output: boolean true | |
var_dump($x === $y); // Output: boolean false | |
var_dump($x != $y); // Output: boolean false | |
var_dump($x !== $y); // Output: boolean true | |
var_dump($x < $y); // Output: boolean false | |
var_dump($x > $y); // Output: boolean false |
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 | |
$score = 300; | |
if ($score >= 200 && $score <= 400) { | |
echo "Hai vinto il peluche medio"; | |
} |
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 | |
$x = 127; // 1111111 | |
$y = 85; // 1010101 | |
var_dump(decbin($x & $y)); // Output: string(7) 1010101 | |
var_dump(decbin($x | $y)); // Output: string(7) 1111111 | |
var_dump(decbin($x ^ $y)); // Output: string(6) 101010 | |
var_dump(decbin(~ $x)); // Output: string(64) 1111111111111111111111111111111111111111111111111111111110000000 | |
var_dump(decbin($x << 1)); // Output: string(8) 11111110 |