blog personale

debug con php

continuo lo spam php-tecnologico.
PHP gestisce a meraviglia gli array, da una funzione è addiruttura possibile vedere tutte le variabili utilizzate (comprese quelle passate in get, post, sessioni, cookie e ambiente). Allora perchè non fare una funzioncina da includere a fondo di ogni pagina quando il sito è ancora in fase di sviluppo per debuggare il codice ?
Sfruttando al print_r (stampa strutturata dell’array n-dimensionale), suggerisco di stampare il contenuto di $_GET, $_POST $_SESSION e infine $_GLOBALS

include "debug.php";   //da commentare per il deploy

debug.php
function f() //stampo vars in textarea
{
  print 
"<textarea rows=20 cols=100>";
  print 
"\$_POST = ";  print_r($_POST);
  print 
"\n\$_SESSION = "print_r($_SESSION);
  print 
"\n\$_GET = "print_r($_GET);
  print 
"\n\$GLOBALS = "print_r($GLOBALS);
  print 
"</textarea>";
}
f();

Screenshot:


Leave a comment

Name: (Required)

E-mail: (Required)

Website:

Comment:

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


 

Ultimi post

About Me

Blog tecnico/geek di Elvis. Chi sono ? studente & web developer freelance. Vedi la pagina "about me" per altre info.

scontiPHP