The short answer
Older textbooks often sorted fungi into three main groups based on the sexual spores they produce: zygomycetes, ascomycetes, and basidiomycetes. Fungi with no known sexual stage were set aside as a fourth group, the imperfect fungi. Some textbooks still describe this scheme, but DNA studies have changed it a great deal.
Zygomycetes: the zygospore group
Zygomycetes form thick-walled sexual spores called zygospores after two compatible hyphae fuse. Bread mold is the familiar example. Their hyphae have few or no cross walls, which is one of the traits used to set the group apart.
Earlier books put these fungi under the label Phycomycetes, a grab bag that also included the water molds, or oomycetes. Water molds are no longer treated as true fungi.
Ascomycetes: the sac fungi
Ascomycetes produce sexual spores, called ascospores, inside sac-shaped structures called asci. The group is large and varied. It includes the yeasts used in baking, brewing, and winemaking, along with morels and truffles. Yeasts are fungi, but they aren’t mushrooms.
Basidiomycetes: the club fungi
Basidiomycetes produce spores on the outside of club-shaped structures called basidia. This group includes gilled mushrooms, shelf fungi (bracket fungi), and puffballs. It also includes rusts and smuts, which are plant pathogens.
Where the imperfect fungi fit
Imperfect fungi, or Deuteromycetes, are known only from their asexual stage. Without a known sexual stage, they couldn’t be sorted into any of the three sexual groups. Older books put them in a catch-all group instead, which is why they are still called imperfect. Counting them, the older scheme has four main kinds of fungi.
Why the scheme has changed
Classifications based on sexual spores have been reworked using DNA sequencing. Many imperfect fungi were later linked to ascomycete or basidiomycete relatives. Zygomycota has also been broken up into several separate groups in modern work, and Deuteromycota is no longer used in formal classification. Ascomycota and Basidiomycota hold most known fungal species.
Mycologists still disagree on some details, so check a current mycology source before relying on exact groupings.
What this means for mushroom hunters
Many of the mushrooms foragers pick are basidiomycetes, such as gilled mushrooms, boletes, and puffballs. Morels and truffles are ascomycetes. The taxonomy of a mushroom places it within these groups and the ranks above them. That’s a different question from whether a mushroom is edible.
Closely related species can differ greatly in toxicity, and some of the most dangerous mushrooms are basidiomycetes. Knowing a mushroom’s group won’t tell you whether it’s safe. Have any wild mushroom identified by an experienced expert.