Sorry to hear that bob. As to if it's legal - AFAIK it is, as it happened to me a short time ago too - out of the total blue a few of us were told we were being made redundant, and were told we could work out our month's notice, but the mployer didn't really want us to take that option, or we could walk as of from that very second and get paid a month in lieu.
Naturally enough, we walked that very day. Plus we didn't get statutory redundancy - I was about 2 weeks short of the 2 yrs minimum continuous period (although had been working on a contractual basis for years before that but that didn't count :mad

.
Do however check to make sure you get paid any holiday pay due etc.
Go and sign on even if you are waiting on P45 as this will start your claim being processed and you will have continuity of stamps.
You may find it harder than you think to find a new job, especially at this time of year, but you may be happy to take something temporary in the run up to xmas, as there would be many employers looking for workers for the xmas period but finishing up at end of Dec.
I know you were looking for another job anyway, but be prepared for a fit of the blues to hit you out of nowhere, I thought I was OK when it happened, was positive about it even, but still, you may get the burst of anger/bewilderment/sadness out of the blue, and seeing as it was so sudden (told and let go same day), the shock may take a while to set in as you realise you didn't really get to say goodbye properly to your co-workers and clients that you've been working with over the years.
However, just let it wash over you, and pick yourself up and get on with things. hey - you have a holiday to look forward to at least! I had to cancel mine when I got made redundant! Best of luck with the job hunt.