如何在php中以某种模式生成引用号

I would like to generate a sequential number.

basically I have a form and on that form is a textbox for a reference number - I would like that number generated. Ideally I would like it to be in the format of 'MB.P1.A, all sequential, nothing random.

I am not sure how to go about this. whether it needs to be a database thing or text file thing.

MB is constant but the number after P will change randomly as well as the last letter.

How can I do this in php?

This function will help you to achieve what you want.

function returnRandomRefNumber(){
    return "MB.P".rand(0,9).chr(rand(65,90));
}