If I had a passcode lock on my iPhone and if people try to hack it will they open it?

Last time my 1st period teacher took away my iPhone for using it in class and I didn't have it back until after school and what make me worried is that I had my Facebook account and all of my other accounts and I was worried that if my teacher went through my stuff and my question is if I had a passcode lock did he went through my stuff even though I had a passcode lock?

Well, legally teachers can search through your phone; but you can try to prevent that by adding a passcode, which yes, can be hacked through if you know what you are doing.

1. The teachers can't search your phone for just taking it away.
2. If you have a passcode on it then you really have nothing to worry about.