immpaginazione print_r

Salve a tutti,

sapete se c' un modo per far fare una impaginazione pi leggibile quando si invoca print_r($obj)?

nel mio caso,lanciando print_r( $errors);

mi compare l'output:

ArrayObject Object ( [exception] => Zend_Session_Exception Object ( [message:protected] => Session must be started before any output has been sent to the browser; output started in C:\www\zf1\bootstrap.php/26 [string:private] => [code:protected] => 0 [file:protected] => C:\Programmi\ZendFramework\library\Zend\Session.php [line:protected] => 359 [trace:private] => Array ( [0] => Array ( [file] => C:\Programmi\ZendFramework\library\Zend\Session\Namespace.php [line] => 116 [function] => start [class] => Zend_Session [type] => :: [args] => Array ( [0] => 1 ) ) [1] => Array ( [file] => C:\Programmi\ZendFramework\library\Zend\Controller\Action\Helper\FlashMessenger.php [line] => 72 [function] => __construct [class] => Zend_Session_Namespace [type] => -> [args] => Array ( [0] => FlashMessenger ) ) [2] => Array ( [file] => C:\Programmi\ZendFramework\library\Zend\Controller\Action\HelperBroker.php [line] => 328 [function] => __construct [class] => Zend_Controller_Action_Helper_FlashMessenger [type] => -> [args] => Array ( ) ) [3] => Array ( [file] => C:\Programmi\ZendFramework\library\Zend\Controller\Action\HelperBroker.php [line] => 190 [function] => _loadHelper [class] => Zend_Controller_Action_HelperBroker [type] => :: [args] => Array ( [0] => FlashMessenger ) ) [4] => Array ( [file] => C:\www\zf1\controllers\IndexController.php [line] => 9 [function] => getHelper [class] => Zend_Controller_Action_HelperBroker [type] => -> [args] => Array ( [0] => FlashMessenger ) ) [5] => Array ( [file] => C:\Programmi\ZendFramework\library\Zend\Controller\Action.php [line] => 497 [function] => indexAction [class] => IndexController [type] => -> [args] => Array ( ) ) [6] => Array ( [file] => C:\Programmi\ZendFramework\library\Zend\Controller\Dispatcher\Standard.php [line] => 237 [function] => dispatch [class] => Zend_Controller_Action [type] => -> [args] => Array ( [0] => indexAction ) ) [7] => Array ( [file] => C:\Programmi\ZendFramework\library\Zend\Controller\Front.php [line] => 911 [function] => dispatch [class] => Zend_Controller_Dispatcher_Standard [type] => -> [args] => Array ( [0] => Zend_Controller_Request_Http Object ( [_requestUri:protected] => /zf1/bootstrap.php [_baseUrl:protected] => /zf1/bootstrap.php [_basePath:protected] => [_pathInfo:protected] => [_params:protected] => Array ( [controller] => index [action] => index [module] => default [error_handler] => ArrayObject Object *RECURSION* ) [_aliases:protected] => Array ( ) [_dispatched:protected] => 1 [_module:protected] => default [_moduleKey:protected] => module [_controller:protected] => error [_controllerKey:protected] => controller [_action:protected] => error [_actionKey:protected] => action ) [1] => Zend_Controller_Response_Http Object ( [_body:protected] => Array ( ) [_exceptions:protected] => Array ( [0] => Zend_Session_Exception Object *RECURSION* ) [_headers:protected] => Array ( ) [_headersRaw:protected] => Array ( ) [_httpResponseCode:protected] => 200 [_isRedirect:protected] => [_renderExceptions:protected] => [headersSentThrowsException] => 1 ) ) ) [8] => Array ( [file] => C:\Programmi\ZendFramework\library\Zend\Controller\Front.php [line] => 224 [function] => dispatch [class] => Zend_Controller_Front [type] => -> [args] => Array ( ) ) [9] => Array ( [file] => C:\www\zf1\bootstrap.php [line] => 30 [function] => run [class] => Zend_Controller_Front [type] => :: [args] => Array ( [0] => controllers ) ) ) ) [type] => EXCEPTION_OTHER [request] => Zend_Controller_Request_Http Object ( [_requestUri:protected] => /zf1/bootstrap.php [_baseUrl:protected] => /zf1/bootstrap.php [_basePath:protected] => [_pathInfo:protected] => [_params:protected] => Array ( [controller] => index [action] => index [module] => default ) [_aliases:protected] => Array ( ) [_dispatched:protected] => 1 [_module:protected] => default [_moduleKey:protected] => module [_controller:protected] => index [_controllerKey:protected] => controller [_action:protected] => index [_actionKey:protected] => action ) )

diciamo che non immediato....

Andrea

inviato 9 anni fa
cybaSsh
X 0 X
echo "<pre>";
print_r( $errors);
echo "</pre>";

oppure guardi la sorgente HTML

:bye:

risposto 9 anni fa
Xscratch
X 0 X

hem... si certo... credo comunque di aver trovato qualcosa di utile sul sito it.php.net

function print_r_html($data,$return_data=false)
{
  $data = print_r($data,true);
  $data = str_replace( " ","&nbsp;", $data);
  $data = str_replace( "\r\n","<br>\r\n", $data);
  $data = str_replace( "\r","<br>\r", $data);
  $data = str_replace( "\n","<br>\n", $data);

  if (!$return_data)
    echo $data; 
  else
    return $data;
}

oppure includendo la libreria open source krumo (scaricabile da sourceforge) .

Ciao.

Andrea

risposto 9 anni fa
cybaSsh
X 0 X

figo krumo, non lo conoscevo! grazie

risposto 9 anni fa
Xscratch
X 0 X
Effettua l'accesso o registrati per rispondere a questa domanda