When electricity is passed through a conductor, it produces a magnetic field.
An electric current can produce magnetic fields. Electric currents are caused by the movement of electrons in a conductor. A common example of this is when you turn on an electric appliance such as a fan or hair dryer. The flow of electrons through the wire causes a magnetic field to form around the wire.