dump_variables.php
来自「《PHP和MySQL Web开发》(第三版) Source」· PHP 代码 · 共 55 行
PHP
55 行
<?php
// these lines format the output as HTML comments
// and call dump_array repeatedly
echo "\n<!-- BEGIN VARIABLE DUMP -->\n\n";
echo "<!-- BEGIN GET VARS -->\n";
echo '<!-- '.dump_array($_GET)." -->\n";
echo "<!-- BEGIN POST VARS -->\n";
echo '<!-- '.dump_array($_POST)." -->\n";
echo "<!-- BEGIN SESSION VARS -->\n";
echo '<!-- '.dump_array($_SESSION)." -->\n";
echo "<!-- BEGIN COOKIE VARS -->\n";
echo '<!-- '.dump_array($_COOKIE)." -->\n";
echo "\n<!-- END VARIABLE DUMP -->\n";
// dump_array() takes one array as a parameter
// It iterates through that array, creating a single
// line string to represent the array as a set
function dump_array($array)
{
if(is_array($array))
{
$size = count($array);
$string = '';
if($size)
{
$count = 0;
$string .= '{ ';
// add each element's key and value to the string
foreach($array as $var => $value)
{
$string .= "$var = $value";
if($count++ < ($size-1))
{
$string .= ', ';
}
}
$string .= ' }';
}
return $string;
}
else
{
// if it is not an array, just return it
return $array;
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?