2

I don't understand, I want show some vars during my dev. I work on windows and Linux.

On windows, When I use print_r for show $form or $form_state (from the hook form_alter). There isn't any problem, when the page is loaded, I can see the content of theses vars.

But on linux, when I use print_r, I see the RAM (via top/htop) rise continuously until 4Go and my OS freeze x) The page I request is never loaded.

I don't understand because I don't think have a special configuration. My configuration is recent.

On Linux (Mint)

php -v : 5.6.14 apache2 -v : 2.4.10 (Raspbian)

Solution

Activate the sub-extend drupal Kint from the devel package :)

1 Answer 1

3

You might not like the answer, but it's still true: Don't use print_r() for $form/$form_state, entity or other complex objects. It just doesn't work.

Try kint() from the devel module instead, make sure to install the kint submodule too.

4
  • Devel (dpm) use print_r =) And I get infinit loop when I use dpm with $form, $form_state.. Feb 15, 2016 at 20:04
  • 1
    That's why I said kint() and not dpm().
    – Berdir
    Feb 16, 2016 at 6:24
  • 1
    kint() is not a replacement for dpm(), because dpm() uses drupal message to store the debug output in a session and to show it on the next page, that is loaded. Perfect would be a dpm that uses kint instead of kprint_r.
    – 4uk4
    Feb 16, 2016 at 11:07
  • Hmmm, thanks guys ! I see the sub-extend (of devel) kint wasn't actived. When I actived it, I finally can show contents of form, form_state... Feb 16, 2016 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.