In John's gospel he wrote what Jesus said before he raised Lazarus from the grave: "Then Jesus looked up and said, Father, I thank you that you have heard me. I knew that you always hear me, but I said this for the benefit of the people standing here, that they may believe that you sent me.
BTW, I'm glad you mentioned this. The explanation is in the verse itself. He is making an exception to the rule. The prayer is not spoken so that people can hear the words of his prayer to God, but so that they will believe his authority when the miracle is performed. The motive is quite clearly different from his instructions on private prayer.
Upvote
0