Elenco file PHP nella cartella:
Sorgente di Controllo_tipi_variabili.php:
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8">
<title>Controllo Tipi Variabili</title>
<style>
body {
font-family: Arial, sans-serif;
background: #0f1724;
color: #e6eef6;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
}
.container {
background: rgba(255,255,255,0.05);
border: 1px solid rgba(255,255,255,0.1);
border-radius: 12px;
padding: 24px;
max-width: 800px;
width: 100%;
box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
h1 {
margin-top: 0;
font-size: 22px;
color: #38bdf8;
text-align: center;
}
.output {
background: rgba(255,255,255,0.08);
padding: 16px;
border-radius: 8px;
font-family: monospace;
line-height: 1.6;
}
hr {
border: none;
border-top: 1px dashed rgba(255,255,255,0.3);
margin: 16px 0;
}
h5 {
margin: 8px 0;
color: #facc15;
}
button {
margin: 20px auto 0 auto;
display: block;
background: #387ef8;
color: white;
padding: 10px 15px;
border: none;
border-radius: 6px;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
background: #38bdf8;
}
</style>
</head>
<body>
<div class="container">
<h1>Controllo Tipi Variabili</h1>
<div class="output">
<?php
$i=5;
$d=1.33;
$s="ciao";
$v=array(1,2,3);
echo "i = $i ? ".gettype($i)."<br>";
echo "d = $d ? ".gettype($d)."<br>";
echo "s = $s ? ".gettype($s)."<br>";
echo "v = array(".implode(", ", $v).") ? ".gettype($v)."<br>";
if (gettype($i) == "integer")
echo "<br><strong>i e' un intero</strong>";
else if(gettype($d) == "double")
echo "<br><strong>d e' un double</strong>";
else if(gettype($s) == "string")
echo "<br><strong>s e' una stringa</strong>";
else if(gettype($d) == "array")
echo "<br><strong>v e' un array</strong>";
$tipi = array(
"integer" => "intero",
"float" => "numero float",
"double" => "numero double",
"string" => "stringa",
"array" => "vettore"
);
echo "<br><hr><h5>Stampa Vettore</h5>";
$variabili = array($i,$d,$s,$v);
error_reporting(E_ERROR | E_PARSE);
foreach($variabili as $tipo){
if(is_array($tipo)){
echo "[".implode(", ", $tipo)."] ? ".$tipi[gettype($tipo)]."<br>";
} else {
echo "$tipo ? ".$tipi[gettype($tipo)]."<br>";
}
}
?>
</div>
<button onclick="history.back()">Torna alla Home</button>
</div>
</body>
</html>