A broken door handle can be a real headache, especially when it locks on its own and can't be opened. This problem is particularly bad if the knob is on an inside door, since it stops you from being able to get into that room without climbing through a window. You can always break down the door and buy a new one. But before going all out, try removing the broken knob once and for all and replacing it before it can cause any more trouble.
Slide a butter knife between the door and the door frame about 3 inches above the knob if you're not on the side of the door where the two screws holding the knob to the door are exposed. Slide until the knife hits the door bolt, then push the knife in and work it to slide the bolt back out of the door jamb to open the door.
Unscrew the two screws if you're on that side of the door, using a cross-tip screwdriver. This will cause the knob on your side of the door to come off. The knob on the other side of the door is no longer attached, either, so it will be loose and eventually will fall off. Look inside the doorknob hole and locate the latching mechanism. Notice the hole in the long piece of metal.
Stick the flat-tip screwdriver into the hole and twist it clockwise. You may need to apply pressure toward the right. This will trigger the latch and the door will open.
Remove the two screws holding the plate by the bolt sticking out of the side of the door, using a cross-tip screwdriver. Take out all pieces of the latching mechanism and replace the entire doorknob.