The examples in this article describe the extension and inheritance usage of PHP classes. Share to everyone for your reference. as follows:
<?php class Thread {var $topic;//Post theme var $body;//post content var $date;//Post release Time Var $author; Post author//function thread for initializing variable function thread () {//initialization variable}//function Send to submit new post function send () {/ /detection of the legality of variables after the insert operation to store variables in the database}//function edit to edit post function edit () {///check the legality of variables to perform an update operation to store variables in the database}//Function Del Ete is used to remove the Post function Delete () {//To detect the author's permissions will remove related data from the database}} class Mainthread extends Thread {var $id; /post number Var $board; Post in the discussion area Var $allowreply;
Allow reply//constructor to initialize variable function mainthread ($id, $board, $allowreply) {//For initializing variable} function Send () {////Check the legality of a variable to perform an insert operation to store the variable in the database Parent::send ();//////////////////// Operation to store variables in the database Parent::edit (); The edit function for calling the base class} $th = new Thread;
Creates a new object if ($th instanceof Thread)//If the object $th is a thread type, the output is yes echo "yes";
else echo "No"; ?>
I hope this article will help you with your PHP programming.