[TOC]
## 代碼復用機制`trait`
旨在用細粒度和一致的方式來組合功能。 無法通過 trait 自身來實例化。它為傳統繼承增加了水平特性的組合;也就是說,應用的幾個 Class 之間不需要繼承
```
<?php
trait?ezcReflectionReturnInfo?{
????function?getReturnType()?{?/\*1\*/?}
????function?getReturnDescription()?{?/\*2\*/?}
}
class?ezcReflectionMethod?extends?ReflectionMethod?{
????use?ezcReflectionReturnInfo;
????/\*?...?\*/
}
class?ezcReflectionFunction?extends?ReflectionFunction?{
????use?ezcReflectionReturnInfo;
????/\*?...?\*/
}
?>
```
`trait`方式引入的類庫需要注意優先級,從基類繼承的成員將被`trait`插入的成員所覆蓋。優先順序是來自當前類的成員覆蓋了`trait`的方法,而`trait`則覆蓋了被繼承的方法。
`trait`類中不支持定義類的常量,在`trait`中定義的屬性將不能在當前類中或者繼承的類中重新定義。
為了解決多個`trait`在同一個類中的命名沖突,需要使用`insteadof`操作符來明確指定使用沖突方法中的哪一個。
以上方式僅允許排除掉其它方法,`as`操作符可以將其中一個沖突的方法以另一個名稱來引入。
## xdebug
1. 點擊[xdebug](https://xdebug.org/download.php)下載插件(php版本、位數、VC版本、線程安全要對應)

2. 修改php.ini配置文件
```
[Xdebug]
zend_extension="E:\IM\im_webserver\php\ext\php_xdebug-2.5.5-5.6-vc11.dll"
xdebug.idekey = "vagrant"
xdebug.default_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler="dbgp"
```


## 獲取本機ipve地址
```
$ip = gethostbynamel($_ENV['COMPUTERNAME']);
$ip = $ip[count($ip) - 1];
```
## static
~~~
class a {
protected $a = "";
public function __construct($msg) {
$this->a = $msg;
}
public static function echo1($msg) {
$static = new static($msg);
print_r($static->a);
}
}
a::echo1('333');
~~~
## 交換變量值
`[$a, $b] = [$b, $a];`
## 查看配置文件位置
```php --ini```
## 查看php編譯安裝的參數
```php -i | grep Configure```
- php
- 安全
- php7
- 特性
- 編譯安裝
- 源碼整體框架
- 基本變量
- thinkphp3.2.3
- thinkphp5.0
- thinkphp6.0
- laravel
- 配置
- 路由
- artisan控制臺
- eloquent
- tinker
- composer
- 加密解密
- 小知識點
- 數組
- string
- 代碼簡潔之道
- 編譯
- 語法糖
- lumen
- smarty
- 錯題集
- 算法及數據結構
- 線性表結構
- 插入排序
- 冒泡排序
- 數據庫
- mysql
- oracle
- PostgreSQL
- redis
- sqlserver
- 前端
- 備忘
- js
- nodejs
- vue
- css
- electron
- vue
- 語法糖
- colorui使用筆記
- 微信小程序
- 操作系統
- windows
- bat
- 快捷鍵
- linux
- sed
- 問題解決
- git
- docker
- docker-compose
- 正則表達式
- ps
- lua
- 協議相關
- 問題思索
- Golang
- 測試
- 讀取和寫入json配置文件
- 類
- 接口
- mod
- gin
- fyne
- 禪道二次開發
- 服務
- apache
- 漏洞配置
- http server優化
- nginx
- 安裝
- 面試題庫
- freeswitch