While they share some superficial similarities, like their stout body shape and blunt snout, porcupines belong to the order Rodentia, which includes rats, mice, squirrels, and beavers. Pigs, on the other hand, belong to the order Artiodactyla, which includes even-toed ungulates like cows, deer, and hippos.
So, despite some visual resemblances, porcupines and pigs are actually quite different animals with distinct evolutionary paths.