Codice PHP:
//classe per il tag table
class table implements produce_html {
private $output = "\n<table ";
private $dati = array();
private $attributi = array();
public function __construct($attributi = array()) {
if(count($attributi) < 1) {
throw new Exception('Numero di attributi passati errato, inserisci almeno id!');
}
$this->attributi = $attributi;
}
public function dati($dati = array()) {
if(count($dati) < 1) {
throw new Exception('Non hai passato dei dati per la tabella!');
}
$this->dati = $dati;
}
public function genera_html() {
foreach($this->attributi AS $attributo=>$valore) {
$this->output .= $attributo . '="' . $valore . "\">\n";
}
foreach($this->dati AS $dato) {
$dato = ($dato istanceof produce_html) ? $dato->genera_html() : $dato;
$this->output .= "\n<tr><td>" . $dato . "</td></tr>\n";
}
$this->output .= "\n</table>\n\n";
return $this->output;
}
}
Ragazzi mi dice:
Parse error: syntax error, unexpected T_STRING
e la riga incriminata è
Codice PHP:
$dato = ($dato istanceof produce_html) ? $dato->genera_html() : $dato;
Non vorrei che non mi riconosca "istanceof" e mi legga "produce_html" come stringa.. Ma mi pare strano.. vedete qualche apice di troppo??
Grazie grazie :master: