Check if function has been called yet

前端 未结 5 2108
挽巷
挽巷 2020-12-20 23:02

New to OOP in PHP

One of my functions requires another function to be executed before running. Is there a way I can check this?

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-20 23:35

    Language-agnostic answer:

    Keep a (static or global) "state" variable and set a flag within the prerequisite function when it's called. Check the flag in the dependent function to decide whether it's allowed to run.

提交回复
热议问题