1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8// \brief Command to print PHP variables to debug console 9require_once('lib/debug/debugger-ext.php'); 10 11/** 12 * \brief Command to print PHP variables to debug console 13 */ 14class DbgPrint extends DebuggerCommand 15{ 16 /// \b Must have function to announce command name in debugger console 17 function name() 18 { 19 return 'print'; 20 } 21 /// \b Must have function to provide help to debugger console 22 function description() 23 { 24 return 'Print PHP variable. Indexes are OK.'; 25 } 26 /// \b Must have function to provide help to debugger console 27 function syntax() 28 { 29 return 'print $var1 $var2 var3 ...'; 30 } 31 /// \b Must have functio to show exampla of usage of given command 32 function example() 33 { 34 return 'print $_REQUEST' . "\n" . 'print $_SERVER["REQUEST_URI"] $my_private_variable'; 35 } 36 /// Execute command with given set of arguments. 37 function execute($params) 38 { 39 global $debugger; 40 require_once('lib/debug/debugger.php'); 41 // 42 $this->set_result_type(TEXT_RESULT); 43 $result = ''; 44 $vars = explode(" ", $params); 45 foreach ($vars as $v) { 46 if (strlen(str_replace('$', '', trim($v))) == 0) { 47 continue; 48 } 49 $result .= $v . ' = '; 50 $result .= trim($debugger->str_var_dump($v)) . "\n"; 51 } 52 return $result; 53 } 54} 55 56/// Class factory to create instances of defined commands 57function dbg_command_factory_print() 58{ 59 return new DbgPrint(); 60} 61