The danger of using a dimmer as a ceiling fan control is the amount of current flowing through the switch to the motor. Motors require a high amount of current to get the motor moving. Your switch has to be able to handle the in rush of current or else it could potentially cause a fire if it happened to overheat. The current going into the motor is slowed by a starting capacitor which will momentarily stop and start current until the motor reaches about 3/4 its operating speed.
Wall mounted speed control switches contain either solid state circuits or capacitors that can control the mount of current going to the fan field of the fan wiring. These are designed for motor control rather than lighting control.
Also, you would need to make sure your fan is already wired for a switch. Some people do it and don’t have any problems but I personally wouldn’t risk it.