239. " and if you fear (an enemy or danger), then (pray) on foot or riding;
but when you are safe, then remember allah as he has taught you
that which you did not know."

commentary:
in this verse it emphasizes that you cannot abandon establishing
prayers even in the most grievous conditions such as in the battlefield.
but in circumstances like that many of the obligations of prayer are
diminished, for example: being to the direction of qiblah, the
performances of bowing and prostration in ordinary manner, and so on.
hence, it says:

" and if you fear (an enemy or danger), then (pray) on foot or riding; ..."

therefore, constant attending to prayers is not only for the time
of security and safety, but canonical prayers should be kept always and
in any condition.

"...but when you are safe, then remember allah as he has taught you
that which you did not know."

and, when you are in security, then prayers in this status have to
be kept in the ordinary form and with all their ritual manners and
conditions.

it is clear that the thankfulness of servants due to this divine
teaching, in which he has taught them the way of establishing prayers
both in the secured time and in fear, is by way of the very performance
of them, as they should be kept.