If I recall how the header works, it can't be called after you've sent anything besides headers and cookies. Maybe you've already sent something before this code gets executed.
dog_mu
@dog_mu
Best posts made by dog_mu
Latest posts made by dog_mu
-
RE: PHP: copy() Permission Denied
-
RE: Gotos considered harmful, but break considered OK?
A construct I've used several times is:
if (!AllocationOne()) goto cleanup1;
if (!AllocationTwo()) goto cleanup2;
if (!AllocationThree()) goto cleanup3;
<etc>
<do real work>
DeAllocationThree();
cleanup3:
DeAllocationTwo();
cleanup2:
DeAllocationOne();
cleanup1:
This lets me not only recover from whatever fails, but also set error codes to tell the user what went wrong. The only other thing I use goto for is to temporarily bypass sections of code.
-
RE: Javascript calculation
When I've done floating-point calculations that had to be accurate, I
would set up the code to round off after every few operations, or I
would go the "deciamal" route: multiply by a scaling factor and use
ints. Occasionally, I've re-arranged equations to reduce the
impact of round-offs, as mentioned in the "What Every Programmer Should
Know about Floating Point" article.