PhDs in the UK: should you know supervisor beforehand? (context: undergrad/integrated masters student in a math-related field, planning on a PhD in a CS-related field)
In Asia (at least in India and Singapore), students are generally expected to personally know (and ideally have worked with) their to-be supervisors before starting their PhD.
So it's common for undergrads to try to contact professors for summer projects -- and professors generally like it, because they get free work done and get a good feel of who may be a good graduate student for them to take later.
In the end of my second year at a UK university, I emailed a couple of professors (in other UK universities) asking for a summer project with some semi-generic topic ideas, but quickly realized this was a major faux-pas since:

I didn't receive a reply, positive or negative, suggesting that it was regarded as spam.
I found that some other professors -- though not the ones I had emailed -- had put notices on their website expressing their dislike of summer internship requests.
I saw a question here that seemed to suggest that such requests are considered spam, although that may only be for generic formats for mass-emailing professors (which is not what I did).

So I realize that I don't really know how &quot;getting into a PhD programme&quot; works in the UK. Are you not expected to know a supervisor beforehand? Or do students generally look for other (perhaps less time-consuming for professors) ways to network with potential supervisors, like emailing them about their work?
It is not necessary to know a professor before applying for a PhD in the UK. I have so far supervised 8 PhD students, only one of whom I knew before they started their PhD.
There are two routes to a PhD in the UK. First is to apply for an advertised position or program. This is how the majority of PhDs are recruited, but it is also usually only open to home students. The second is to find the funding yourself (either through a non-UK government scheme, an NGO or a wealthy benefactor) and to write to the supervisor laying out your experience, your desire to do a PhD (and why with them), and what your source of funding is.
I don't take unpaid interns as I feel it unfairly advantages those that can afford to do an unpaid internship at the expense of those that can't. My university runs several schemes that fund summer internships and my professional society also has a summer studentship fund. Unfortunately, I only have the capacity to take one, or at a push, two summer students a year, and I would normally recruit these from our own undergraduate body. While I try to reply to all requests for internships, I get several a day during some parts of the year, and sometimes they slip through the cracks.