Skip to content

Instantly share code, notes, and snippets.

Flavio Biscaldi flaviors200

Block or report user

Report or block flaviors200

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@flaviors200
flaviors200 / if-statement.php
Last active Jun 4, 2019
Conditional statements: if
View if-statement.php
<?php
$x = 10;
$y = 8;
if ($x > $y) {
echo "$x è maggiore di $y"; // Output: 10 è maggiore di 8
}
View php.ini
[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:
View bitwise-operators.php
<?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
View logical-operators.php
<?php
$score = 300;
if ($score >= 200 && $score <= 400) {
echo "Hai vinto il peluche medio";
}
View comparison-operators.php
<?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
View arithmetic-operators.php
<?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
View assignment-operators.php
<?php
$x = 30;
echo $x."\n"; // Output: 30
$x += 30;
echo $x."\n"; // Output: 60
$x -= 20;
echo $x."\n"; // Output: 40
View string-functions.php
<?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
View string-as-array.php
<?php
$lastName = "Biscaldi";
echo $lastName[0];
echo $lastName[3];
echo $lastName[4];
// Output Bca
You can’t perform that action at this time.