var_dump and print_r cause white screen

My template is very simple:

get_header();
$new_p = get_posts(array('post_type' => 'post', 'numberposts' => 6));
get_footer();

whenever I put var_dump($new_p); or print_r($new_p); below $new_p = get_posts(array('post_type' => 'post', 'numberposts' => 6));, it gives me the white screen.

Why on Earth would it do it??

This code is OK, though:

var_dump(wp_get_recent_posts(array('post_type' => 'tdlrm_store_item', 'numberposts' => 8), OBJECT));

Any ideas?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Actually, memory was exhausted. Someone has copy-pasted an actual 2MB base64-encoded image into the post content, var_dump was trying to output it. Had to delete the image via PHPMyAdmin, because the WP editor won’t open. Once it had been deleted, the problem was gone.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x