Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9015205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:41:35+00:00 2026-06-16T03:41:35+00:00

For PHP debugging I made myself a pre() function like this: function pre($data) {

  • 0

For PHP debugging I made myself a pre() function like this:

function pre($data)
{
    echo '<pre>'.print_r($data).'</pre>';
}

But it’s not displaying line breaks as it should. By example, I get all this on one line:

Template_model Object ( [id] => 1 [type] => 1 [shortname] => default [is_custom] => 0 [is_open] => 1 [options] => Array ( [id] => 1 [name] => background_color [value] => #6699CC [type] => 0 [campaign_id] => 8 [user_id] => 11 [template_id] => 1 ) )

Some parts should have linebreaks. What am I doing wrong?

This may sound newb, but I can’t understand what I do wrong when I’ve been using this for years.

Please not that I call my pre function before there is any other HTML displayed on the page.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:41:36+00:00Added an answer on June 16, 2026 at 3:41 am

    You need to print the pre before print_r() as print_r() handles its own output. Like this:

    function pre($data) 
    {
        echo '<pre>';
        print_r($data);
        echo '</pre>';
    }
    

    I am however not sure if it would preserve line-breaks if you use the optional parameter (specifying that you want it to return the output instead). Let’s see what codepad has to say about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PHP code: echo date(c); //out put like this 2012-06-19T20:37:44+05:30 echo date(d M, Y); //out
I'm not sure if this is a trivial questions but in a PHP class:
Ok this is probably just me not knowing enough about php but here it
I have made a function simular to the print_r function in php. Is there
We use echo or print_r to get value of variables while debugging PHP code.
I'm stuck with this problem I made an HTML Array, but I can't read
I have eclipse setup with PHP debugging - that's not a problem. The problem
For debugging php code I use MacGDBp but it has its quirks: it shows
I'm debugging some PHP code written by an outsourcing company (I'm not a PHP
I just threw this together to help in debugging some PHP scripts. As you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.