Created
November 8, 2024 15:10
-
-
Save xtetsuji/7ea8a27b7eb0d21f3b01d8023149b8e1 to your computer and use it in GitHub Desktop.
PHP version xtrace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@xtetsuji ➜ /workspaces/codespaces-blank $ php tick_test.php | |
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port). | |
Executing /workspaces/codespaces-blank/tick_test.php on line 9 | |
Hello | |
Executing /workspaces/codespaces-blank/tick_test.php on line 12 | |
Executing /workspaces/codespaces-blank/tick_test.php on line 13 | |
Executing /workspaces/codespaces-blank/tick_test.php on line 14 | |
Result: 10 | |
Executing /workspaces/codespaces-blank/tick_test.php on line 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(ticks=1); | |
function trace_execution() { | |
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; | |
echo "Executing {$backtrace['file']} on line {$backtrace['line']}\n"; | |
} | |
register_tick_function('trace_execution'); | |
// サンプルコード | |
echo "Hello\n"; | |
$a = 5; | |
$b = $a * 2; | |
echo "Result: $b\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment