Package Home

Zend Framework 2 Documentation (Manual)

PHK Home

File: /modules/zend.debug.html

Size:11517
Storage flags:no_autoload,compress/gzip (30%)

Dumping Variables — Zend Framework 2 2.4.2 documentation

Dumping Variables

The static method Zend\Debug\Debug::dump() prints or returns information about an expression. This simple technique of debugging is common because it is easy to use in an ad hoc fashion and requires no initialization, special tools, or debugging environment.

Example of dump() method

1
Zend\Debug\Debug::dump($var, $label = null, $echo = true);

The $var argument specifies the expression or variable about which the Zend\Debug\Debug::dump() method outputs information.

The $label argument is a string to be prepended to the output of Zend\Debug\Debug::dump(). It may be useful, for example, to use labels if you are dumping information about multiple variables on a given screen.

The boolean $echo argument specifies whether the output of Zend\Debug\Debug::dump() is echoed or not. If TRUE, the output is echoed. Regardless of the value of the $echo argument, the return value of this method contains the output.

It may be helpful to understand that Zend\Debug\Debug::dump() method wraps the PHP function var_dump(). If the output stream is detected as a web presentation, the output of var_dump() is escaped using htmlspecialchars() and wrapped with (X)HTML <pre> tags.

Tip

Debugging with ZendLog

Using Zend\Debug\Debug::dump() is best for ad hoc debugging during software development. You can add code to dump a variable and then remove the code very quickly.

Also consider the ZendLog component when writing more permanent debugging code. For example, you can use the DEBUG log level and the stream log writer to output the string returned by Zend\Debug\Debug::dump().

Table Of Contents

Previous topic

Zend\Db\Metadata

Next topic

Introduction to Zend\Di

This Page

Note: You need to stay logged into your GitHub account to contribute to the documentation.

Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Login with your GitHub account.
  2. Go to Dumping Variables on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.

For more information about the PHK package format: http://phk.tekwire.net