Can an illegal immigrant leave the country get married to a citizen and then come back without trouble?

I am not familiar with the immigration laws of the UK. In the United States, it depends on how the person came to the country and how long they've been "illegal." If the person snuck across the border, s/he cannot get a greencard without first going home, even if s/he marries a US citizen. If s/he came on a visa but overstayed, then s/he can adjust status to get a greencard without leaving. If s/he has been in the United States illegaly for over a year, s/he will not be able to come back for 10 years once s/he leaves. The only way to overcome the 10 year bar is if a US citizen spouse or child can prove that the alien being barred for 10 years would cause extremely unusual hardship him/her (the citizen, not the alien.)