나는 debug_backtrace에 대해 알고 있지만 내가 원하는 목적이 아니다.
나는 백 트랙 기능을 사용하지 말 것을 주장하지만, 여전히 나는 당신이 기능을 백 트랙이라고 불러올 때 로그를 남기고 싶을 때 편리하다고 생각한다.
아이디어는 if 조건을 디버그하여이 코드를 평가할 때마다 상수에 저장된 미리 정의 된 pf 코드가 있다는 것입니다.
만약 당신이 proposal을 받고 있다면, if 문은 아무 것도 평가하지 못하도록하므로 코드의 속도는 영향을받지 않습니다. 그것이 당신을 위해 작동한다면, 당신은 당신의 필요에 맞게 수정할 수 있으며, 더 많은 레벨을 추적 할 수 있습니다.
내 견해를 확인하는 것은 완전한 예입니다. 내가 옳은 것을 이해하지 못했고, 이것이 당신이 찾고있는 것이 아니라면, 사과드립니다! 이 test1.php
<?PHP
class test1
{
public static function a()
{
test2::b();
}
}
?>
마지막에게 있습니다 TEST2입니다 test.php
<?php
define ('__SITE_PATH',realpath(dirname(__FILE__)).'/');
ini_set('log_errors', 1);
ini_set('error_log', __SITE_PATH.'my_error_log.log');
include 'test1.php';
include 'test2.php';
define (__DEBUG_EVAL, '
$dbt = debug_backtrace();
error_log(
"\n".
"Parent function file: " . $dbt[1]["file"] . "\n" .
"Parent function class: " . $dbt[2]["class"] . "\n" .
"Parent fiunction name: " . $dbt[2]["function"] . "\n" .
"Par. fiunc. called from line: " . $dbt[2]["line"] . "\n" .
"Child function file: " . $dbt[0]["file"] . "\n" .
"Child function class: " . $dbt[1]["class"] . "\n" .
"Child fiunction name: " . $dbt[1]["function"] . "\n" .
"Child fiunc. called from line: " . $dbt[1]["line"] . "\n" .
"\n"
);
');
test1::a();
?>
:
당신이 파일이 예제를 확인하십시오. <?PHP
class test2
{
public static function b()
{
if(defined('__DEBUG_EVAL')) eval(__DEBUG_EVAL);
echo 'Hello!';
}
}
?>
이 PHP은 결과입니다 :
[13-Apr-2012 14:37:18]
Parent function file: C:\PHP-GTK\MyProjects\Electre\test1.php
Parent function class: test1
Parent fiunction name: a
Par. fiunc. called from line: 29
Child function file: C:\PHP-GTK\MyProjects\Electre\test2.php
Child function class: test2
Child fiunction name: b
Child fiunc. called from line: 7
http://php.net/manual/en/function.rename-function.php 뭔가 다른 원래의 함수 이름을 바꿉니다 ,이 이름으로 자신의 함수를 만들고 내부의 원래 함수를 호출하십시오. 단점은 PECL에서 APD를 설치해야한다는 것입니다. – strkol