忍者ブログ
[PR]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。



2024/04/20 01:13 |
PHP1-42:ちょっと便利なdBug

dBug March 22, 2007
http://dbug.ospinto.com/

簡易デバッグにはvar_dump()を使用することが多いと思いますが、配列の中身が巨大な場合等あまり見やすいとは言えません。
といって本格的なデバッグを行うほどでもない、そんなときに便利なのがdBugです。
なんといっても使い方が超簡単。
requireしてnewするだけです。

index.php 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
    
    require_once('../dBug.php');
    
    class testclass{var $hoge;function hoge(){return $this->hoge;}}
    
    
    $test1=array('hoge','xx'=>'yy',array(1,2,'2'=>'3'));
    $test2=new testclass();
    $test3=imagecreatefromjpeg('index.jpg');
    $test4='<xml>xmlxml<a>aa</a><b c="cc">bb</b></xml>';
    
    $dbug=new dBug($test1);
    $dbug=new dBug($test2);
    $dbug=new dBug($test3);
    $dbug=new dBug($test4,'xml');

デフォルトで配列、オブジェクト、MySQLやGD等のリソース型に対応しています。
また、何気に知られていませんが、第二引数に'xml'を指定するとXMLのパースも行えます。

実行結果は以下のようになります。
$test1 (array)
0 hoge
xx yy
1
array
0 1
1 2
2 3
$test2 (object)
hoge [empty string]
hoge [function]
$test3 (resource)
gd
Width 70
Height 70
Colors 0
$test4,'xml' (xml document)
xmlRoot
xml element
xmlName xml
xmlAttributes  
xmlText xmlxml
xmlComment  
xmlChildren
xml element
xmlName a
xmlAttributes  
xmlText aa
xmlComment  
xmlChildren  
xml element
xmlName b
xmlAttributes
array
c cc
xmlText bb
xmlComment  
xmlChildren  

邪魔な要素は閉じたりすることもできて便利です。
 てか、そんなことよりこんなJavaScriptを普通に受け入れる忍者ブログが恐ろしい。 
PR


2008/12/26 14:06 | Comments(0) | TrackBack() | PHP

トラックバック

トラックバックURL:

コメント

コメントを投稿する






Vodafone絵文字 i-mode絵文字 Ezweb絵文字 (絵文字)



<<JavaScript2-9:JavaScriptで犯罪者作成装置 | HOME | PHP1-41:PHPでrunkit>>
忍者ブログ[PR]