Skip to content

Instantly share code, notes, and snippets.

View flaviors200's full-sized avatar

Flavio Biscaldi flaviors200

View GitHub Profile
@flaviors200
flaviors200 / string.php
Created May 16, 2019 00:26
String data type
<?php
$car = "Ferrari";
$model = 'F40';
echo "Auto $car \n";
echo "Modello $model\n";
/*
Output
@flaviors200
flaviors200 / float.php
Last active May 15, 2019 23:45
Float data type
<?php
$float = 123.30;
$float2 = 120e-3; // Sintassi con esponente
echo $float."\n";
echo $float2;
/*
Output
@flaviors200
flaviors200 / integer.php
Last active May 22, 2019 16:50
Integer data type
<?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
@flaviors200
flaviors200 / non-boolean.php
Last active May 22, 2019 16:38
Non Boolean data types
<?php
$isLoaded = 1;
if ($isLoaded) {
echo "Carico\n";
} else {
echo "Non carico\n";
}
// Output: Carico
@flaviors200
flaviors200 / boolean.php
Created May 15, 2019 15:30
Boolean type
<?php
$isLoaded = true;
if ($isLoaded) {
echo "Carico";
} else {
echo "Non carico";
}
// Output: Carico
@flaviors200
flaviors200 / comments.php
Created May 14, 2019 21:17
Comments in PHP
<?php
// Questo è un commento
# Questo è un altro commento
/*
Autore: Flavio
Linguaggio: PHP
Oggetto: Commento su più righe
*/
@flaviors200
flaviors200 / constants.php
Last active May 14, 2019 16:33
PHP Constants
<?php
define('SOFTWARE_VERSION', 7.2);
echo "Versione del software ".SOFTWARE_VERSION;
//Output: Versione del software 7.2
@flaviors200
flaviors200 / variables.php
Last active May 14, 2019 14:08
Variables
<?php
$name = 'Flavio';
$age = 36;
$_country = 'Italia';
$car1 = 'Clio';
echo "Il mio nome è $name, vivo in $_country, ho $age anni e guido una $car1";
//Output: Il mio nome è Flavio, vivo in Italia, ho 36 anni e guido una Clio
@flaviors200
flaviors200 / gettype-function.php
Last active May 10, 2019 01:04
Gettype function
<?php
$string = "foo";
$integer = 0;
echo "$string è ".gettype($string).", $integer è ".gettype($integer); // foo è string, 0 è integer
@flaviors200
flaviors200 / weak-typing.php
Last active May 10, 2019 01:01
Weak typing
<?php
$string = 'foo';
$integer = 0;
if ($string == $integer) {
echo "I valori sono uguali";
} else {
echo "I valori non sono uguali";
}