Britain has voted to leave the European union. How will this affect PhD students in the UK, in Europe and beyond?
The exact form of Britain's exit (or "Brexit") is as yet unclear. The result of the referendum is not legally binding so in principle parliament could ignore it, though this seems unlikely. The first major step will be the formal notification to the EU of the intention to leave, which will then trigger a negotiation period of up to two years to decide the terms of the exit. This has not happened yet, and at the time of writing it isn't clear when it will.
So it will take some time before anything is decided, and in the short-term it probably won't affect your studies much, and in the long-term things will reach some kind of equilibrium. In the medium-term, though, the next 2 to 5 years or so, there's a lot of uncertainty and a few potentially worrying possibilities.

Funding and collaborations
The EU funds a significant amount of academic research in the UK, as well as pan-european collaborations involving UK researchers. If you are already on an EU-backed PhD project, it seems unlikely that you'll lose funding that's already been assigned to you (though pretty much everything is uncertain at this point).
But even if it doesn't affect you directly it may affect people around you in negative ways, which may then have negative consequences for you if, for example, your supervisor relies on European funding or collaboration for their research (or their job).
Now it could be that Britain reaches some kind of deal whereby funding and collaboration carries on in much the same way as it does now. If not, it seems unlikely that all collaboration will cease, but until things are sorted out the big problem is the uncertainty; in academia as in business most people are hesitant to make big commitments in uncertain circumstances. I've heard anecdotal evidence that some European collaborations are already being affected, with some academics being reluctant to join long-term projects with UK researchers.
Jobs and freedom of movement
One of the most prominent and persistently stated aims of the pro-Brexit campaign was to limit immigration. Currently, it is very easy for EU citizens to move between member states for work or study, but this might change - at least between the UK and Europe - in the next few years.
Again, we don't know what will happen, if anything. If you're already on a PhD programme it probably won't affect your studies too much. The big potential problem lies in getting work after you graduate.
Following my PhD, I had to move to France to find a postdoc job that matched my specific skills. My second postdoc was in Spain. In the worst post-brexit case, it could be much harder for British PhD students to get jobs in Europe. It won't be impossible, but the administrative burden of employing a non-EU citizen could make it harder to compete in an already very competitive job-market.
Of course, not everyone wants to work abroad; but your prospects of academic work in the UK could be affected too. Postdoc jobs need to be paid for by someone; without EU money there could be fewer available.
What to do if you're already on a PhD programme
In the short-term, stay calm and keep working, but talk to people and stay informed about the circumstances that might affect you.In the long-term, your best defence is to develop really, really solid research skills and get really, really good at what you do. Whatever happens, you'll always have more options if you have a well-developed set of marketable skills.
What to do if you're applying for a PhD in the UK
Ask prospective supervisors if they are funded by the EU and if they might be affected by Brexit. This doesn't mean you shouldn't work with EU funded supervisors, but you have to know what you're getting into.
If you're a PhD student outside the EU
The pro-Brexit campaign argued that leaving the EU would allow the UK to take the best people from everywhere, rather than favouring those from Europe. In principle, this could mean more opportunities to come to the UK to work.
Like everything else though, it's unclear whether this will actually happen. Whether it does or not, your best strategy is still to get as good as you can at what you do.
Anything to add?
If you've been affected by or are worried about the effects of Brexit, or if you have something useful to contribute, please comment below. If you've been following events on news websites or Facebook you'll know that these discussions can get very ugly very quickly, so I won't allow any off-topic or inflammatory posts. Stay calm, re-read before posting, and don't write anything you wouldn't say to a colleague's face.