The quills have little barbs on them, that are like small needles pointing the opposite way.
So when you get a porcupine quill stuck in you, it's really hard to get it out.
This helps the porcupine protect itself.