If you mean that the script will run up to apoint, but then fails - in that case you can insert "print" statements to output to the browser where you are so far.
if ($case_1) {
print "<p>made it into case 1 and var_x = $var_x\n";
...rest of IF.....
}