Is it possible for a phone to be hacked/have a virus?

This came to mind recently, I was wondering is it possible to get a virus or be hacked from a link sent to you on your iPhone? It's been awhile since this happened to me, but I had received a text message that included my name saying someone tagged you in a photo. I asked, "Who is this?" It was an automated message, but it asked if I was a student at a local high school. A high school I was supposed to attend, but I had been homeschooled for years prior, i hadn't finished middle school locally either. Less than five or so people had my phone number from that school so I was curious and clicked the link they gave. This is where my memory gets foggy, I don't remember if I clicked or not, but let's say I did. I do not remember when this occurred, so I can't say if this happened on my current or old phone. I also do not remember what the link brought me to. I don't believe I filled any information and I'd like to think I didn't download anything, like an app or anything. I was wondering, if from what I said, if there was a possibility that someone put anything malicious on my phone? I know I sound paranoid, but I'm curious.

I also have downloaded a pdf file that I put in the Apple 'notes'. This pdf was from someone I had talked to online, we connected through a fitness or workout social media. It was basically a pdf of a book by someone. I had that since February, but I deleted it a day or a few days ago.

There are two ways a device can be infected/hacked. One is by the user installing an infected app, the other is a vulnerability gets exploited in the software. IOS limits apps to only the Apple App Store and they check every app before letting it on, therefore the first way isn't really likely. The second way, a vulnerability getting exploited, can be more likely, however it's not very likely at all. IOS has been built by Apple and is secure. It can and does get vulnerabilities however, Apple will patch them and send out an update as soon as they can to fix it. If you keep up with updates, it becomes very unlikely that your phone can be hacked. It's not to say it's impossible though. Clicking a link could trigger an exploit and your device could get hacked if you have an unpatched or unknown vulnerability. Your phone is probably fine though. It was most likely a way to get information from you, such as your Apple ID and password. If you are still worried, you can reset to factory.