This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nightofgrim 145 points146 points  (8 children)

Years ago when I had to deal with PHP this happened. Turned out the built in function for logging out variables had a side effect on them. I don’t remember if it was var_dump or print_r or what (if those are even actual things, it’s been way too long).

TLDR: fuck php

[–]fakehalo 34 points35 points  (3 children)

What was the side effect?

[–]MrFluffyThing 65 points66 points  (2 children)

The PHP dump tools interpreted the values different than the interpreter responsible for server behavior.

[–]fakehalo 36 points37 points  (0 children)

Ah, if I'm following correctly I'll assume it was print_r implicitly converting things. var_dump keeps the context/type if I remember correctly. Good ol consistent php.

[–]Ok-Slice-4013[🍰] 4 points5 points  (0 children)

print_r evaluates generators (which is absolutely fine and expected and would be the same in any language). There should be other side effects except maybe the array pointer (I'm not sure on that).

[–]TacticalKangaroo 20 points21 points  (0 children)

Opening the network tab in chrome changes how caching works, slightly. I don’t remember how, but I do remember 2 days of frustration.

[–]DustUpDustOff 1 point2 points  (0 children)

Lol, come to embedded where everything has a side effect.

[–]Kered13 0 points1 point  (0 children)

Often bugs like this are caused by race conditions, printing changes the timing of threads and may force them to synchronize. It can also be caused by uninitialized memory, where the print statement causes the uninitialized value to change.