Date: 02/22/00
- Next message: badmanhk <email protected>: "[PHPLIB] Error when access "PREVIOUS PAGE"!!!????"
- Previous message: Richard Valk: "[PHPLIB] Session problems, table not locked ?"
- Next in thread: Gary Bickford: "[PHPLIB] Array/object traversal shows php3, phplib data"
- Maybe reply: Gary Bickford: "[PHPLIB] Array/object traversal shows php3, phplib data"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The following code is a useful little toy. Include it at the end of the
auto_append footer. Then, if $dbg is >0, all the information you want
to know is available. I have included three example usages - the PHP
variables, the PHPLib variables, and a test array. There's never
anything in $GLOBALS or $ENV - I don't know what the correct usage is in
those cases. I'm open to suggestion/improvement.
==================================================
<? if (!isset ($dbg)) { // Turn on/off for debugging ?>
</body>
</html>
<?
exit;
} else {
function pray ($data, $functions=0) {
// pray - short for print_array
// Traverse the argument array/object recursively
and print an ordered list.
// Optionally show function names
// Written by Gary Bickford (garyb <email protected>)
// Copyright 2000 by Gary Bickford - usage and
modification is free to all.
// Conditions of use - YMMV, caveat emptor.
// NB: This is a *** HUGE SECURITY HOLE *** in the
wrong hands!!
// It prints all the variables it can find
// This includes your database connection
information, magic keys and session data!!
if($functions!=0) { $sf=1; } else { $sf=0 ;} // This
kluge seemed necessary on one server.a
if (isset ($data)) {
if (is_array($data) || is_object($data)) {
if (count ($data)) {
echo "<OL>\n";
while (list ($key,$value) = each
($data)) {
$type=gettype($value);
if ($type=="array" ||
$type == "object") {
printf
("<li>(%s) <b>%s</b>:\n",$type, $key);
pray
($value,$sf);
} elseif (eregi
("function", $type)) {
if ($sf) {
printf
("<li>(%s) <b>%s</b> </LI>\n",$type, $key, $value);
//
There doesn't seem to be anything traversable inside functions.
}
} else {
if (!$value) {
$value="(none)"; }
printf
("<li>(%s) <b>%s</b> = %s</LI>\n",$type, $key, $value);
} }
echo "</OL>end.\n";
} else {
echo "(empty)";
} } } }
// $mylist contains various other arrays, so we can find out everything
in one traverse.
$mylist = array ( "HTTP_POST_VARS"=>array(),
"HTTP_GET_VARS"=>array(), "HTTP_COOKIE_VARS"=>array(),
"GLOBALS"=>array(), "ENV"=>array());
$phplib = array ("sess"=>"","user"=>"", "perm"=>"", "auth"=>"");
while (list ($key, $value) = each ($mylist)) {
if (isset ($key) && count ($$key) ) {
$mylist[$key]=$$key; }
}
echo "<h2>PHP Variables</h2>\n";
pray ($mylist);
while (list ($key, $value) = each ($phplib)) {
if (isset ($key) && count ($$key) ) {
$phplib[$key]=$$key; }
}
// Now the much longer PHPLib data. If you want to see function
names, add ",1" in the arguments
echo "<h2>PHP Lib Variables</h2>\n";
pray ($phplib);
echo"<h2>A simple test case mixing numeric & assoc.
arrays</h2>\n";
$test=array (
1,
2,
3 => array(
"a" => "breakfast",
"b" => "lunch",
"c" => array(
"I." => "toast",
"II." => "peanut butter",
"III." => "jam"
),
"d"=>"dinner"
),
4
);
pray($test);
}
?>
</body>
</html>
=================================================================
--
"Cyber is cyber, life is life."
Gary E Bickford mailto:garyb <email protected>
Consultant http://www.fxt.com/
FXT Corporation tel:541-383-2749
mail:PO BOX 1808, SISTERS OR 97759
ship:66265 JERICHO ROAD, BEND OR 97701
-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.
- Next message: badmanhk <email protected>: "[PHPLIB] Error when access "PREVIOUS PAGE"!!!????"
- Previous message: Richard Valk: "[PHPLIB] Session problems, table not locked ?"
- Next in thread: Gary Bickford: "[PHPLIB] Array/object traversal shows php3, phplib data"
- Maybe reply: Gary Bickford: "[PHPLIB] Array/object traversal shows php3, phplib data"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

