The drop is always movingYou know that saying about standing on the shoulders of giants? Drupal is standing on a huge pile of midgetsAll content management systems suck, Drupal just happens to suck less.Popular open source software is more secure than unpopular open source software, because insecure software becomes unpopular fast. [That doesn't happen for proprietary software.]Drupal makes sandwiches happen.There is a module for that

print_r is your friend?

Submitted by nk on Wed, 2008-03-26 06:05

Someone said this in #drupal today. I long wanted to blog about this. I never use print_r. There is no need for it, var_export is far superior IMO -- if I need to write a quick script which actually does something on the data, I can copypaste the output into PHP code. Little but annoying things like escaping apostrophes are handled too, so it's even useful for dumping strings. Of course, var_dump is also useful as that dumps type info -- how cool it would be if it would do that in a PHP comment and then it would also render valid PHP code as debug output.

Commenting on this Story is closed.

Submitted by theborg on Wed, 2008-03-26 13:55.

Agree totally,

I use var_export with TRUE as the second paramenter so the output can be redirected to drupal message function:

drupal_set_message('< pre >'. var_export(array_to_dump,TRUE) .'< /pre >');

You can define this as a macro in your favorite editor to quick & dirty debug arrays or variables.

Submitted by Anonymous on Wed, 2009-10-07 16:25.

Someone said this in #drupal today. I long wanted to blog about this. I never use print_r. There is no need for it, var_export is far superior IMO -- if I need to write a quick script which actually does something on the data, I can copypaste the output into PHP code. Little but annoying things like escaping apostrophes are handled too, so it's even useful for dumping strings. Of course, var_dump is also useful as that dumps type info -- how cool it would be if it would do that in a PHP comment and then it would also render valid PHP code as debug output.