Home  >  Q&A  >  body text

Can PHP directly call functions in a class without using new?

I have to do something new every time, which is very unaccustomed. Can I use the functions in the class directly? The purpose of using the class is to look at the static attributes inside, so that when operating redis or mysql, automatic connection and connection reuse can be realized without the need to perform the connection operation multiple times. If I have to add new every time I use it. Isn’t that the same as before?

I don’t know if there is such a method. I just started to relearn class recently.

只争朝夕只争朝夕689 days ago1939

reply all(1)I'll reply

  • 只争朝夕

    只争朝夕2022-12-23 12:39:14

    I just thought of using static variables. The experiment was successful. I don’t need to consider rewriting everything with classes for the time being. I just don’t know if there are any side effects.

    reply
    0
  • Cancelreply