본문으로 바로가기

[PHP] Xdebug의 기본 기능

category Helloworld!/PHP 2014. 7. 21. 16:50
function fix_string($a)
{
    echo "Called @ ".
        xdebug_call_file(); // : 현재 실행되고있는 파일
        ":".
        xdebug_call_line(); // : 몇번째 라인에서 실행했는가 (즉, fix_string함수가 호출된 곳을 말함. 따라서 12가 뜸)
        " from ".
        xdebug_call_function(); // : 어떤 함수가 fix_string 함수를 호출했는가. 따라서 여기서는 특정 함수가 fixx_string을 호출한게 아니므로 main에서 호출되었다고 나옴
}

$ret = fix_string(array('Derick'));
$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";
    /*
     * xdebug_memory_usage
     * : 현재 메모리를 얼마나 사용하고 있는지를 확인한다.
    */
}
echo xdebug_time_index()."\n";
for($i=0; $i<3; $i++){
    echo xdebug_time_index()."
\n"; sleep(1); /* * xdebug_time_index * : 1초간 (sleep(1)) 동작되는 시간을 출력 */ }
// 전역변수 열람
ini_set('xdebug.dump.GET', '*');
ini_set('xdebug.dump.SERVER','*');
xdebug_dump_superglobals();

* 또한 Object나 배열 등을 var_dump로 출력하면 사람이 보기 편한 형태로 컬러링되어 보여짐


참고사이트 : http://opentutorials.org/module/411/3756