Skip to content

Instantly share code, notes, and snippets.

@frasten
Created October 28, 2011 14:37
Show Gist options
  • Save frasten/1322419 to your computer and use it in GitHub Desktop.
Save frasten/1322419 to your computer and use it in GitHub Desktop.
esempi-classi.php
<?php
error_reporting(E_ALL);
class Matematica {
function quadrato($num) {
if (! is_numeric($num)) die();
return $num * $num;
}
}
echo Matematica::quadrato(5);
class Penna {
var $colore;
function __construct() {
echo "Mi sto costruendo.<br/>";
$this->colore = "red";
}
function scrivi($testo) {
echo "<span style='color: $this->colore'>$testo</span><br/>";
}
}
$miaPenna = new Penna();
$miaPenna->scrivi("ciao");
$miaPenna->colore = "green";
$miaPenna->scrivi("ciao2");
echo "ciao";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment