Home >Backend Development >PHP Tutorial >Simple application of php abstract class_PHP tutorial
All right, the parent class postParent is defined as abstract, which stipulates that subclasses must reimplement the buildHTML() method. This method does not have curly braces. If there are curly braces, an error will be reported regardless of whether there is content or not.
The more I look at it now, the more I feel that there is no need to use abstract classes in this code, and inheritance is useless. Well, there is nothing good to say. . . . .
In addition, I separated mysql outside, so calling the method is very troublesome
1, instantiate readArticle first
2, mysql query, the parameters come from readArticle::getSQL();
3, return mysql The result resource is given to readArticle::fetchResult( $result );
4, readArticle::buildHTML(); returns HTML
If it is a list loop output, just call 3 and 4 repeatedly