What is - if any - the difference between PhD and doctor? In a Simpsons episode of season 25 the dialoge 

Monsarno Rep: Say hello to our chief scientist.
Everyone: Augh! Sideshow Bob!
Sideshow Bob: Dr. Sideshow Bob.
Homer: Real doctor or PhD?
Sideshow Bob: PhD.


takes place. In my country there is only a doctor and I thought a PhD would be exactly that in Anglo-Saxon countries. I would like to know is there a difference in the USA between a PhD and a doctor?  Especially: What did they mean in the dialogue?

Edit: In hindsight this may be a duplicate, but originally it wasn't because I did not know that the "doctor" of the dialogue was about a medical doctor.
It's not the difference between "doctor" and "PhD". It's the difference between "real doctor" and "PhD". 

"Real doctor"=someone who performs surgery, prescribes medication, etc.

"PhD"=Doctor of Philosophy

The joke is PhD's aren't "real" doctors. When someone says "I need a doctor", they aren't talking about needing an expert in the jackets of 1860s Chicago or Teichmueller spaces. They need someone to help with their medical ailment.