PHP面向对象
<?php
class Buyer{
public $name;
public $money = 0;
const PI = 3.14;
public function display(){
echo __CLASS__;
}
}
$b = new Buyer();
echo $b -> money;
$b -> money = 100;
unset($b->name);
$b -> age = 20;
<?php
class Saler{
public $name;
protected $money = 100;
private $age = 20;
public function getAll(){
echo $this->name,$this->money,$this->age;
}
}
$b = new Saler();
$b -> name = 'xiaosheng';
echo $b->name;
<?php
class Saler{
public function __construct($c,$m){
echo __CLASS__;
$this->count = $c;
$this->money = $m;
}
}
$s1 = new Saler(100,100);
$s2 = new Saler(1010,1010);
var_dump($s1,$s2);
<?php
class Saler{
public function __destruct($c,$m){
echo __FUNCTION__;
}
}
$s = new Saler();
unset($s);
<?php
class Saler{
const PI = 3.14;
}
echo Saler::PI;
<?php
class Saler{
public $money = 0;
public static $count = 0;
public static function showCunt(){
echo Saler::$count,__FUNCTION__;
}
}
echo Saler::$count;
Saler::showCunt();
$s = new Saler();
echo $s->money;