Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.www.php > #20882 > unrolled thread
| Started by | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| First post | 2016-06-02 10:17 +0200 |
| Last post | 2016-06-02 14:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to it.comp.www.php
catturare l'output di var_dump alex <1j9448a02@lnx159sneakemail.com.invalid> - 2016-06-02 10:17 +0200
Re: catturare l'output di var_dump Alessandro Pellizzari <shuriken@amiran.it> - 2016-06-02 10:00 +0100
Re: catturare l'output di var_dump alex <1j9448a02@lnx159sneakemail.com.invalid> - 2016-06-02 14:00 +0200
| From | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| Date | 2016-06-02 10:17 +0200 |
| Subject | catturare l'output di var_dump |
| Message-ID | <nioq3j$1ma8$1@gioia.aioe.org> |
class Test
{
function __debugInfo()
{
return array('...', '...', '...');
}
}
$test = new Test();
// ------------- METODO1:
$out1 = var_export($test, true);
// ------------- METODO2:
ob_start();
var_dump($test);
$out2 = ob_get_clean();
// visualuzzazuine output...
echo
$out1.PHP_EOL.
$out2.PHP_EOL
;
// scrittura su file...
file_put_contents('/tmp/testlogloglog10.log1234', $out1);
file_put_contents('/tmp/testlogloglog11.log1234', $out2);
Osservate soprattutto i due metodi (METODO1 e METODO2).
METODO1:
La funzione var_esport non fornisce lo stesso output fornito dalla
funzione var_dump.
Inoltre non viene richiamato il *metodo magico* __debugInfo.
METODO2:
Riesco ad ottenere esattamente il risultato che voglio, ma devo usare il
costrutto **ob_start()...ob_get_clean()** che non è il massimo
dell'eleganza.
Esiste quindi una funzione simile a var_dump, che però restituisce
l'output senza ricorrere ad espedienti *poco eleganti*?
[toc] | [next] | [standalone]
| From | Alessandro Pellizzari <shuriken@amiran.it> |
|---|---|
| Date | 2016-06-02 10:00 +0100 |
| Message-ID | <draau6F5bcgU1@mid.individual.net> |
| In reply to | #20882 |
On 02/06/2016 09:17, alex wrote: > Esiste quindi una funzione simile a var_dump, che però restituisce > l'output senza ricorrere ad espedienti *poco eleganti*? print_r(..., true) anche se non è identica. Bye.
[toc] | [prev] | [next] | [standalone]
| From | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| Date | 2016-06-02 14:00 +0200 |
| Message-ID | <nip75q$br8$1@gioia.aioe.org> |
| In reply to | #20883 |
Il 02/06/2016 11:00, Alessandro Pellizzari ha scritto: > On 02/06/2016 09:17, alex wrote: > >> Esiste quindi una funzione simile a var_dump, che però restituisce >> l'output senza ricorrere ad espedienti *poco eleganti*? > > print_r(..., true) anche se non è identica. > > Bye. > potrebbe andare bene, grazie!!!
[toc] | [prev] | [standalone]
Back to top | Article view | it.comp.www.php
csiph-web