Telling the boss you've gotten another job offer - is this basically a resignation? Watch
If an employer did dismiss you for this I'm pretty sure it would be considered illegal, assuming you were a permanent employee.
Still a dumb thing to tell your boss if you're not prepared to leave.
Where I used to work, a lot of people would go to the boss saying "I have a job offer for *x amount* match it or I leave" its a bit cheeky but a lot of employers will play ball.
If you go in and say "I have a job offer and I am intending to leave" generally a lot of employers won't beg, but if they do, its still largely advised not to bother, apparently the vast majority of cases where the employee stays, they are gone within 6 months anyway.
In terms of formality, it isn't a resignation until you hand in your resignation which triggers your notice period etc.