Listing Every Session Variable
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Listing Every Session Variable
Is there a way to make PHP print:
$_SESSION['name'] = hi
$_SESSION['name2'] = asdf
$_SESSION['name3'] = hh
which is pretty much just it finding all of the sessions variables and then printing it. What I just want is a list of all of the variables on the page, so that I can be lazy an not have to find them all
$_SESSION['name'] = hi
$_SESSION['name2'] = asdf
$_SESSION['name3'] = hh
which is pretty much just it finding all of the sessions variables and then printing it. What I just want is a list of all of the variables on the page, so that I can be lazy an not have to find them all
Code: Select all
<?php
print_r($_SESSION);
?>Code: Select all
print_r($_SESSION);
// or if your REALLY lazy..
print_r($GLOBALS);- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
A number of programmers keep something like this around. I stick it in config.php and comment out the echo in production code to minimize stray print statements.
Code: Select all
function dump($var) {
echo '<pre>' . print_r($var, 1) . '</pre>';
}(#10850)
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Yeah i do that.arborint wrote:A number of programmers keep something like this around. I stick it in config.php and comment out the echo in production code to minimize stray print statements.Code: Select all
function dump($var) { echo '<pre>' . print_r($var, 1) . '</pre>'; }
What's wrong with:arborint wrote:A number of programmers keep something like this around. I stick it in config.php and comment out the echo in production code to minimize stray print statements.Code: Select all
function dump($var) { echo '<pre>' . print_r($var, 1) . '</pre>'; }
Code: Select all
<?php
print_r($_SESSION);
?>This really depends on your needs... For me, most of the time the extra data from var_dump() is useless and confusing - Not because I don't understand itR4000 wrote:I prefer to use var_dump() myself...
It gives you alot more detailed info than print_r().
But thats just me
(i deal with alot of binary reverse engineering in PHPso i need to know true string lengths ect.)