While it would be insane to get a PhD if you had to pay for it, at least in the US you are paid a stipend (if not a good one) so you can generally avoid any debt. There is definitely an opportunity cost though.
If a PhD cost $0, it still costs a craptonne of time.
All the smartest people I know left school when they were 15 (or earlier).