<?php
/*class Ren {public static $color; static function Show () {Ren:: $color; Self:: $color; }} class Car {public static $name; }*//*/abstract class Dongwu {public $dong; Public $jiao; function Chi () {} function Shui () {}}
Interface Extreme abstract class interface dongwu//definition interface, do not add class {} class Ren extends Dongwu {} $d = new ren*//*//interface keywords; interface The method inside the interface does not have the function body//implements the interface to use the keyword; implements, subclasses that do not use extends//implement interfaces must implement each method of the interface
//Interface extremely abstract class interface USB { function Read () { } function W Rite () { } } //mouse class Mouse extends USB { function Read () { echo "inserted mouse"; } function write () { echo "Power you to Mouse"; } } //Keyboard class Jianpan implements USB { function Read () { echo "inserted mouse"; } function Write () & nbsp; { echo "Power you to the mouse"; } $m = new Mouse (); $m->read (); $m->write (); */
Class Ren {public $name; Public $sex; Public $age; function run () {} function Show () {echo ' name stands for name, sex representative, age, and the Run method represents the method of running; }//destructor function __destruct () {//The memory is freed before the object is destroyed, the connection is closed, etc. echo "the object destroyed"; }//When the output object is called, there must be a return value to perform function __tostring () {//return "name for name, sex representative, age for ages, and run method to represent the method of running" return $this-> ; name; }}//Special: _destruct//Execution Time Special: Execute/* At time of object destruction * $r = new Ren (); $r->name = "Zhang San"; Var_dump ($R); */* $r = new Ren (); echo $r; * *
Small knowledge points
/* $a = 10; $b = 20; $c = 25; Unset ($b); if (Isset ($b)) {echo $a + $b, echo $a * $c, echo $sun, echo "<br>", Echo $a * $sum;}
if (Isset ($b)) {echo ' variable B does not exist! "; Exit ();//Quit the program die ("variable B does not exist!") ");//Output error message and exit program} Echo $a + $b; Echo $a * $c; Echo $sun; echo "<br>"; Echo $a * $sum;
$attr = Array (1,2,3,4); $a = "Hello"; Var_dump ($ATTR); Print_r ($ATTR); Print_r ($a); echo "Hello", "AA"; print "VV";
?>
Abstract, interface