Allora ragazzi intanto buongiorno, anzi buonasera a tutti =)
Il problema è il seguente...
Ho una classe (e fin qui tutto ok
), quando la inizializzo in questo modo funziona correttamente (quella che posto è solo la porzione che mi crea problemi, l'ho semplificata per togliere le parti inutili che non mi/ci interessano, quindi parti come $this->parse = "thearray"; in realtà provengono da altre funzioni...):
Codice PHP:
<?php
$thearray[1][id] = "1";
$thearray[1][foo] = "primo";
$thearray[2][id] = "2";
$thearray[2][foo] = "secondo";
$thearray[3][id] = "3";
$thearray[3][foo] = "terzo";
$thearray[4][id] = "4";
$thearray[4][foo] = "quarto";
$thearray[5][id] = "5";
$thearray[5][foo] = "quinto";
$idx = new parsing;
$idx->pa();
class parsing{
function pa(){
$this->parse = "thearray";
$newstyle = $this->parse;
global $$newstyle;
$this->newstyle = $$newstyle;
print_r($this->newstyle);
return $this->newstyle;
}
}
?>
restituisce
codice:
Array ( [1] => Array ( [id] => 1 [foo] => primo ) [2] => Array ( [id] => 2 [foo] => secondo ) [3] => Array ( [id] => 3 [foo] => terzo ) [4] => Array ( [id] => 4 [foo] => quarto ) [5] => Array ( [id] => 5 [foo] => quinto ) )
se invece provo così, cioè richiamando la classe da un'altra classe, mi restituisce NULL (con il var_dump al posto di print_r):
Codice PHP:
<?php
$idxxx = new myf;
$idxxx->myfunc();
class myf{
function myfunc(){
$thearray[1][id] = "1";
$thearray[1][foo] = "primo";
$thearray[2][id] = "2";
$thearray[2][foo] = "secondo";
$thearray[3][id] = "3";
$thearray[3][foo] = "terzo";
$thearray[4][id] = "4";
$thearray[4][foo] = "quarto";
$thearray[5][id] = "5";
$thearray[5][foo] = "quinto";
$idx = new parsing;
$idx->pa();
}
}
class parsing{
function pa(){
$this->parse = "thearray";
$newstyle = $this->parse;
global $$newstyle;
$this->newstyle = $$newstyle;
print_r($this->newstyle);
return $this->newstyle;
}
}
?>
ecco... dove sta il problema?
spero che riusciate ad aiutarmi..