The search for a teen who accidentally fired a gun in a Blanche Ely High School algebra class ended Monday night when the boy's parents turned him in, the Broward Sheriff's Office said.

The 15-year-old Pompano Beach boy was charged with possession of a weapon on school property, carrying a concealed weapon and discharging a firearm in public, sheriff's spokesman Jim Leljedal said. Nobody was hurt.

According to the Sheriff's Office, the boy walked into class with a Glock 9 mm semiautomatic handgun either tucked in his waistband or inside one of his pants pockets. When he sat down, the gun discharged. The bullet ricocheted off the floor, bounced off a wall and lodged in the ceiling.

Investigators said the teen told classmates the explosion was a firecracker. He went into a bathroom and hid the gun in a ceiling vent before sneaking off campus.