커뮤니티

고용노동부, 산업인력공단과 함께하는 강원도 유일한 기업중심 IT전문교육기관 ICT융합캠퍼스만의 특별한교육입니다.
공인 IT숙련기술인의 다양한 접근방법으로 전문가다운 실무교육을 받을 수 있습니다.

Category

교육강좌

서버 PHP 고급 수업 - Xdebug 기본 기능

페이지 정보

작성자 관리자 댓글 0건 조회 2,250회 작성일 20-07-21 14:01

본문

Xdebug 기본 기능

Context

현재 실행되고 있는 함수나 메소드의 맥락을 제공한다. 

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
function fix_string($a)
{
echo "Called @ ".
xdebug_call_file().
":".
xdebug_call_line().
" from ".
xdebug_call_function();
}
$ret = fix_string(array('Derick'));
?>

Memory

1
2
3
4
5
6
7
8
<?php
$text = "coding everybody";
$prev_mem = xdebug_memory_usage();
for($i=0; $i<10; $i++){
$text.=$text;
echo $i.':'.xdebug_memory_usage().':'.(xdebug_memory_usage()-$prev_mem).':'.strlen($text)."\n";
}
?>

실행시간

1
2
3
4
5
6
7
<?php
echo xdebug_time_index()."\n";
for($i=0; $i<3; $i++){
echo xdebug_time_index()."<br />\n";
sleep(1);
}
?>

데이터 출력

xdebug는 var_dump의 출력 방식을 웹과 CLI에 맞게 변경한다.  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
class test {
public $pub = false;
private $priv = true;
protected $prot = 42;
}
$t = new test;
$t->pub = $t;
$data = array(
'one' => 'a somewhat long string!',
'two' => array(
'two.one' => array(
'two.one.zero' => 210,
'two.one.one' => array(
'two.one.one.zero' => 3.141592564,
'two.one.one.one' => 2.7,
),
),
),
'three' => $t,
'four' => range(0, 5),
);
var_dump( $data );
?>

웹에서 실행한 결과 

CLI로 실행한 결과 (xdebug.cli_color의 설정값을 2로 했을 때)

전역변수 열람

1
2
3
4
5
<?php
ini_set('xdebug.dump.GET', '*');
ini_set('xdebug.dump.SERVER','*');
xdebug_dump_superglobals();
?>
  • 트위터로 보내기
  • 페이스북으로 보내기
  • 구글플러스로 보내기

답변목록

등록된 답변이 없습니다.