$GLOBALS はスーパーグローバル変数を含む、ほぼ全てのグローバル変数を保持しています。そこで、print_r で取得できる内容から、正規表現で $_COOKIE と $_FILES を削除したものを表示しています。
※ 同時に get_include_path で、現在の include_path をパス単位で表示しています
<?php
$debug_string = print_r($GLOBALS,true);
$debug_string = preg_replace('/\n\s+\[_[C|F].+?\)/s', '', $debug_string);
print "<br><br><hr>";
print "<pre style='font-weight:bold;white-space:pre-wrap;'>";
print $debug_string;
print "--------------------------------------\n";
print_r( explode(PATH_SEPARATOR,get_include_path()) );
print "</pre>";
?>
print_r は、このように出力結果を文字列として戻す事ができるので、デバッグ時にファイルに出力するのに有効です
▼ 表示結果の例( windows )
Array
(
[_GET] => Array
(
[update_type] => 1
[syain] => 0053
[order] => 氏名
)
[_POST] => Array
(
)
[rpath] => C:\httpd142p\if_skeleton\lightbox99\
[_SESSION] => Array
(
[charset] => utf-8
[iframe_id] => target
)
[server] => localhost
[db_name] => lightbox
[user] => root
[password] => パスワード
[connect] => mysqli Object
(
[affected_rows] => 5
[client_info] => mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $
[client_version] => 50010
[connect_errno] => 0
[connect_error] =>
[errno] => 0
[error] =>
[error_list] => Array
(
)
[field_count] => 12
[host_info] => localhost via TCP/IP
[info] =>
[insert_id] => 0
[server_info] => 5.6.17
[server_version] => 50617
[stat] => Uptime: 15857 Threads: 1 Questions: 288 Slow queries: 0 Opens: 71 Flush tables: 1 Open tables: 64 Queries per second avg: 0.018
[sqlstate] => 00000
[protocol_version] => 10
[thread_id] => 76
[warning_count] => 0
)
[query] => select * from `社員マスタ`
where 管理者 is NULL order by 氏名
[result] => Array
(
[0] => 社員マスタ
[1] => mysqli_result Object
(
[current_field] => 0
[field_count] => 13
[lengths] =>
[num_rows] => 0
[type] => 0
)
[2] => コード名称マスタ
[3] => mysqli_result Object
(
[current_field] => 0
[field_count] => 7
[lengths] =>
[num_rows] => 3
[type] => 0
)
[4] => 社員マスタ
[5] => mysqli_result Object
(
[current_field] => 0
[field_count] => 12
[lengths] =>
[num_rows] => 5
[type] => 0
)
)
[ErrorMessage] =>
[php_errormsg] => Undefined variable: ErrorDisable
[row] =>
[sentaku] =>
[GLOBALS] => Array
*RECURSION*
)
--------------------------------------
Array
(
[0] => .
[1] => C:\php\pear
[2] => C:\httpd142p\if_skeleton\lightbox99\common
[3] => C:\httpd142p\if_skeleton\lightbox99\db
[4] => C:\httpd142p\if_skeleton\lightbox99\view
)
データベースのテーブル別に配列を使って処理すると、後から確認しやすくなります