Home  >  Q&A  >  body text

Class library, how to use it, is there any detailed method?

My MySQL class library in PHP can only define variables after loading it with include. How to use the functions in it? It is useless to write the function name directly.

Please give me a detailed method. Thank you

哈哈哈哈。哈哈哈哈。2314 days ago1243

reply all(6)I'll reply

  • You bad bad

    You bad bad2018-07-13 16:20:55

    Class libraries are generally used for inheritance. Your own project class inherits the extends class library. In this way, you can use the methods and things inside it in your own class. Do you understand this?

    reply
    0
  • Summer

    Summer2018-07-12 12:22:01

    You can take a look at this: https://blog.csdn.net/toume/article/details/80995979

    reply
    1
  • 哈哈哈哈。

    I think only referring to it is equivalent to loading But it doesn't say how to use the functions inside. What should I add before using the function inside? I don’t know mainly this.

    哈哈哈哈。 · 2018-07-12 12:51:31
    Summer

    When you create a new object, just use the object to call the method in the class; for example, $a = new b(); $c = $a->d(); $c is what class b gets after calling class d method of class b. the result of;

    Summer · 2018-07-12 14:14:11
    哈哈哈哈。

    Thank you very much, I understand. Thank you

    哈哈哈哈。 · 2018-07-12 15:12:29
  • 无忌哥哥

    无忌哥哥2018-07-12 11:59:37

    Directly copy the code encapsulated in the class library into your program, and then call it.

    reply
    0
  • 哈哈哈哈。

    Should I copy it directly? Can't I use include to load it? Is it written like this? If I copy it directly, it will feel very bloated.

    哈哈哈哈。 · 2018-07-12 12:01:39
    无忌哥哥

    Include is also OK

    无忌哥哥 · 2018-07-12 13:33:35
  • Cancelreply