Ho caricato uno script che in locale funziona ma sul server remoto no.
Dal server lo stesso script non funziona.
Ma non capisco perchè.
Non riesco a capire come fare il debbug.
Ecco parte dello script:
codice:
<?php
// con questo controllo
// se è un problema di inclusione
if(!include ("include/Class.php")) {
die ('non incluso');
}
$album = 'foto';
$file = "xmlData/".$album.".xml";
// con questo controlo
// se è un problema di file
if (!file_exists($file)) {
die ("problema con $file");
}
// gallery è la classe richiamata sopra
$gallery = new gallery ($file);
// questo è quello che non stampa
// l'array risulta vuoto
print_r ($gallery->data);
Adesso vi posto la classe in questione.
Non mi sembra vi siano cose soggette a differenze di server.
codice:
<?php
class gallery {
// variabili Globali
var $struct;
var $fdata;
var $data;
// costruttore
function gallery ($fdata) {
$this->struct = array();
// è qui che si richiama cio che voglio
// printare
$this->data = $this->parse_file($fdata);
}
// le seguenti tre funzioni servono
// per costruire l'array che mi serve
function startElement($parser, $name, $attrs) {
$tag = array("name"=>$name,"attrs"=>$attrs);
array_push($this->struct, $tag);
}
// mi chiedo se possa essere l'uso di $data
// all'interno di questa funzione!
function data($parser, $data) {
if(trim($data)) {
$this->struct[count($this->struct)-1]['data']=$data;
}
}
function endElement($parser, $name) {
$this->struct[count($this->struct)-2]['child'][] =
$this->struct[count($this->struct)-1];
array_pop($this->struct);
}
// questa funzione richiama le tre di sopra
function parse_file($file) {
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser,
array($this,"startElement"), array($this,"endElement"));
xml_set_character_data_handler($xml_parser,
array($this,"data"));
$parse = xml_parse($xml_parser,
file_get_contents($file));
if(!$parse) {
die("XML parsing error");
xml_parser_free($xml_parser);
}
return $this->struct;
}
}
?>
Si tratta di un parsing di un file xml.
La versione di PHP è 4.3.11
Il server è Linux
Il modulo XML è:
XML Support active
XML Namespace Support active
EXPAT Version expat_1.95.5
come si procede in questi casi?