Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View flaviors200's full-sized avatar

Flavio Biscaldi flaviors200

View GitHub Profile
@flaviors200
flaviors200 / if-statement.php
Last active June 4, 2019 10:23
Conditional statements: if
<?php
$x = 10;
$y = 8;
if ($x > $y) {
echo "$x è maggiore di $y"; // Output: 10 è maggiore di 8
}
@flaviors200
flaviors200 / php.ini
Created May 30, 2019 11:09
PHP ini file
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
<?php
phpinfo();
@flaviors200
flaviors200 / bitwise-operators.php
Last active May 28, 2019 23:05
Bitwise operators
<?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
@flaviors200
flaviors200 / logical-operators.php
Last active June 4, 2019 10:55
Logical operators
<?php
$score = 300;
if ($score >= 200 && $score <= 400) {
echo "Hai vinto il peluche medio";
}
@flaviors200
flaviors200 / comparison-operators.php
Last active May 23, 2019 09:56
Comparison operators
<?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
@flaviors200
flaviors200 / arithmetic-operators.php
Created May 23, 2019 09:20
Arithmetic Operators
<?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
@flaviors200
flaviors200 / assignment-operators.php
Last active May 22, 2019 23:15
Assignment operators
<?php
$x = 30;
echo $x."\n"; // Output: 30
$x += 30;
echo $x."\n"; // Output: 60
$x -= 20;
echo $x."\n"; // Output: 40
@flaviors200
flaviors200 / string-functions.php
Last active May 16, 2019 17:51
String functions
<?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
@flaviors200
flaviors200 / string-as-array.php
Last active May 16, 2019 17:09
String as array
<?php
$lastName = "Biscaldi";
echo $lastName[0];
echo $lastName[3];
echo $lastName[4];
// Output Bca