My school is cool so they let us use our phones during work if we want to listen to music or as a calculator, for research, take pictures of the board, etc. We're even free to use them in the cafeteria, before and after school. It's up to the teachers if they'll let you have your phone out or not, but most of the time they allow us have it out. Is a phone at school necessary? No, but it can assist the student and is pretty convenient.
I never understood why people brang their phones in my middle school though. They weren't allowed no matter what, so I didn't see why people had their phones when you could only really use ot for the 5 minutes you were on the bus and back. You couldn't even use your phones to make important calls if you had to, you had to use the phones in the classroom or the front office.
That being said, if it's against the rules then that's that. If you had your phone out and you were goofing off during class then you probably deserved it anyway.