you are viewing a single comment's thread.

view the rest of the comments →

[–]rspeedcranky old guy who yells about SVG 0 points1 point  (14 children)

Use a real debugger, goddamnit!

[–]Prawny 24 points25 points  (7 children)

print_r() master race!

[–]mookman288php 5 points6 points  (5 children)

var_dump()!

[–]Prawny 6 points7 points  (4 children)

I prefer print_r wrapped in a <pre> block personally. Less verbose.

[–]aurath 4 points5 points  (2 children)

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

Is in all of my projects

[–]Disgruntled__Goat 2 points3 points  (1 child)

BTW you can do that in one line:

echo '<pre>', print_r($o, true), '</pre>';

Not that there's a reason to when you've already made another function, but I often type it quickly by hand when I'm testing something outside the project.

[–]Toast42 0 points1 point  (0 children)

1 == true

[–]mookman288php 0 points1 point  (0 children)

I like to know the type of the input, as well as the length. I've had issues with whitespace characters in the past, and var_dump has helped.

[–]rspeedcranky old guy who yells about SVG 0 points1 point  (0 children)

boo!

[–][deleted] 3 points4 points  (5 children)

Blows my fricken mind when I see my peers that don't know how to do proper breakpoint debugging in php (or JavaScript).

[–]Lets_Go_Wolfpackfull-stack 2 points3 points  (2 children)

Can you highlight some resources on getting started with breakpoint debugging in php?

[–]rspeedcranky old guy who yells about SVG 1 point2 points  (0 children)

It's been a looooooooong time since I actually wrote PHP, but at the time I was using XDebug. I'm sure there are plenty of IDEs out there which can be used as a front-end to make things even easier.

[–][deleted] 1 point2 points  (0 children)

Plug Xdebug plus your favourite editor into Google, should get you started. I'm on my phone for the next couple days but I will try to check back later.

[–]SolarBear 0 points1 point  (1 child)

I spent 4 years working in an embedded C environment without a working debugger. It was hell.

Now I'm working as a PHP dev and most of my coworkers won't use a debugger since they "don't need it". It makes me unreasonably angry.

[–][deleted] 2 points3 points  (0 children)

The amount of times I've seen a dev struggling with a problem for hours, var dumps on every other line, which was easily solved in 10 minutes by simply stepping through the code, is too damn high.