You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.5 KiB

13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
  1. ##########################################################
  2. # .phpdbginit
  3. #
  4. # Lines starting with # are ignored
  5. # Code must start and end with <: and :> respectively
  6. ##########################################################
  7. # Place initialization commands one per line
  8. ##########################################################
  9. # exec sapi/phpdbg/test.php
  10. # set color prompt white-bold
  11. # set color notice green
  12. # set color error red
  13. ##########################################################
  14. # Embedding code in .phpdbginit
  15. ##########################################################
  16. <:
  17. /*
  18. * This embedded PHP is executed at init time
  19. */
  20. /*
  21. * Functions defined and registered by init
  22. * will persist across cleans
  23. */
  24. /*
  25. function my_debugging_function()
  26. {
  27. var_dump(func_get_args());
  28. }
  29. */
  30. /* phpdbg_break(PHPDBG_METHOD, "phpdbg::method"); */
  31. /* phpdbg_break(PHPDBG_FUNC, "my_global_function"); */
  32. /* phpdbg_break(PHPDBG_FILE, "/path/to/file.php:10"); */
  33. /*
  34. If readline is loaded, you might want to setup completion:
  35. */
  36. if (function_exists('readline_completion_function')) {
  37. readline_completion_function(function(){
  38. return array_merge(
  39. get_defined_functions()['user'],
  40. array_keys(get_defined_constants())
  41. );
  42. });
  43. }
  44. /*
  45. Setting argv made trivial ...
  46. argv 1 2 3 4
  47. ^ set argv for next execution
  48. argv
  49. ^ unset argv for next execution
  50. */
  51. function argv()
  52. {
  53. $argv = func_get_args();
  54. if (!$argv) {
  55. $_SERVER['argv'] = array();
  56. $_SERVER['argc'] = 0;
  57. return;
  58. }
  59. $_SERVER['argv'] = array_merge
  60. (
  61. array("phpdbg"),
  62. $argv
  63. );
  64. $_SERVER['argc'] = count($_SERVER['argv']);
  65. return $_SERVER['argv'];
  66. }
  67. :>
  68. ##########################################################
  69. # Now carry on initializing phpdbg ...
  70. ##########################################################
  71. # R my_debugging_function
  72. # R argv
  73. ##########################################################
  74. # PHP has many functions that might be useful
  75. # ... you choose ...
  76. ##########################################################
  77. # R touch
  78. # R unlink
  79. # R scandir
  80. # R glob
  81. ##########################################################
  82. # Remember: *you have access to the shell*
  83. ##########################################################
  84. # The output of registered function calls is not,
  85. # by default, very pretty (unless you implement
  86. # and register a new implementation for phpdbg)
  87. # The output of shell commands will usually be more
  88. # readable on the console
  89. ##########################################################
  90. # TLDR; if you have a good shell, use it ...
  91. ##########################################################