How to ensure the atomicity of the program?

I don"t know if you have encountered a situation like this when you are programming. Sometimes we need to file_put_contents two files. How to ensure that both files are either written successfully or failed? or sometimes we need to send the same message to both clients, or both clients succeed, or both fail?

Php
Oct.09,2021
Menu