BOSTON (AP) _ A man who suffers from severe claustrophobia was trapped for two hours in a courthouse elevator while on his way to plead guilty to income tax evasion, and the judge sentenced him to the time spent in the stuck lift.

Joseph Silvano could have received up to 10 years in prison, but he said the time he served in the elevator on Thursday was not as easy as it sounds.

''Whenever I'm on an elevator, if I'm going to the 15th floor, say, I get off at the seventh and take a breather because of my fear,'' the 51-year-old Boston insurance broker said Friday.

''If the judge gave me a choice right now, between prison and being stuck in that elevator,'' said Silvano, ''I couldn't give (him) an answer. I mean that. I wouldn't want to put anyone through that experience.''

Being squeezed next to 12 other people was punishment enough, he said.

''The first thing I thought of was whether I was going to be able to handle it. I could feel the police officer's holster on the right side of his belt. The first thing that flashed through my mind was, 'If I couldn't handle it, he would pop me in the head.'''

At certain points during the elevator imprisonment, an official in the building contacted the group through an intercom.

To help pass the time, an attorney read newspaper comic strips aloud. Another talked about criminal cases with a police officer jammed next to him, Silvano recalled.

But it was no holiday. ''It was pretty hot, I was sweating like a pig,'' Silvano said.

Meanwhile, in the courtroom on the 15th floor of the 20-story McCormack Building in Boston's Post Office Square, defense attorney Jack Zalkind said he was getting worried.

''It's 2 o'clock and I'm waiting for my client. The judge looks at me and I shrug my shoulders,'' Zalkind recalled. ''The judge is getting exasperated and he says to the clerk, 'If he's not here by 3 o'clock, send out the marshals and have him arrested.''

Zalkind said he frantically called his client's number and then his own office. When that failed to turn up Silvano, he searched all of the courtrooms and called the nearby Suffolk County courthouse, but still found no sign of his client.

''I went to the elevators and I turned to the marshal and I said jokingly, 'I bet he's stuck in the elevator.' ''

Finally, a police officer trapped in the elevator managed to reach a door release button and the passengers were freed by climbing up about five feet onto the eighth floor.

''My God, they (defendants) are not supposed to be punished before they go to court,'' U.S. District Judge Walter Jay Skinner said when Silvano arrived. ''He was for all practical purposes imprisoned for two hours.

Silvano, who will be formally sentenced Jan. 14, could have been sentenced to 10 years in prison and fined $110,000 on the charges of failing to pay $53,343 in 1981 and 1982.

Assistant U.S. Attorney Robert Cordy, who recommended that Silvano get a prison sentence, disputed the judge's decision. ''The U.S. Attorney's office has nothing to do with the repair of elevators,'' he said.

Silvano was convicted in February of mail fraud in connection with a contract for his company to provide health insurance to Boston city employees. He was sentenced to two years in prison in that case but is free pending appeal.