这里定义图片的增删改查trait类
trait HandlePicture
{
protected static $path = "C:/www";
private static function add(): string//增
{
return self::$add;
}
public static function delete(): string//删
{
return self::$delete;
}
public static function update(): string//改
{
return self::$update;
}
public static function get(): string//查
{
return self::$get;
}
}
引入图片的trait类
class DB
{
use HandlePicture;
public static $add = 'add';
public static $delete = 'delete';
public static $update = 'update';
public static $get = 'get';
public function __construct(){}
public function __clone(){}
public function addPicture()
{
echo self::add();
}
}
$addPicture = new DB();//实例化DB类
$addPicture->addPicture();//调用函数