How to quote question? ("Where are you?" yelled my friend.)

Hi. I was wondering if the two examples below are both OK or one is wrong.

“Where are you?” yelled my friend.
“Where are you?” my friend yelled.
what’s the right way of saying/quoting that? Thanks in advance

Hi Butterfly

The first one is correct. Your second sentence is incorrect only because it uses two different types of quotation marks for a single quote.
.

Ok, this was a careless mistake which I edited. But my question is whether the inversion “yelled my friend” or the other structure “my friend yelled” is correct thanks

You can use either one, Butterfly. When only two or three words are used after a quote, it is quite common to place the verb before the subject when the subject is a noun. This word order is less common when the subject is a pronoun. The inverted word order is also not common when it precedes a quote. For example:

“I’ll be right back,” said John. / “I’ll be right back,” John said.

“I’ll be right back,” he said.

John said, “I’ll be right back.”
.

It may be less common, but, apart from question of frequency, can you tell us anything about why one might choose one form over the other?