Check if function has been called yet

前端 未结 5 2114
挽巷
挽巷 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:41

    The other function (the one, which should be called first) will manipulate some state, thats why the second function needs to know about that state. I don't know about a php builtin for that but I would eventually create another function, which returns information about that state, e.g. isReadyToRunSomething, isValid, hasConnection .. or whatever .. then use this function in the beginning of the second function, to see whether it is allowed to run.

提交回复
热议问题