-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,73 @@ | ||
# php-func | ||
|
||
PHP 通用函数库及别名定义,按需加载 | ||
|
||
|
||
|
||
## Install | ||
|
||
```sh | ||
composer require wuding/php-func | ||
``` | ||
|
||
|
||
|
||
## Usage | ||
|
||
### func | ||
|
||
func - 定义函数别名 | ||
|
||
|
||
|
||
#### 说明 | ||
|
||
```php | ||
func ( mixed $function_config [, array $alias_classes = array() [ , mixed $... ]] ) : void | ||
``` | ||
|
||
单独或批量定义函数别名,并预设参数默认值 | ||
|
||
|
||
|
||
#### 参数 | ||
|
||
**function_config** | ||
|
||
要调用或声明的原始函数(名),也可以是批量配置 | ||
|
||
**alias_classes** | ||
|
||
要定义的函数别名或依赖哪些类 | ||
|
||
**...** | ||
|
||
函数的参数 | ||
|
||
|
||
|
||
#### 范例 | ||
|
||
bootstrap.php | ||
|
||
|
||
```php | ||
$Composer = require APP_PATH . '/../vendor/autoload.php'; | ||
|
||
$functions = [ | ||
'_isset' => ['', [], '', null], | ||
'\Func\array_diff_kv' => ['', [], [], [], false], | ||
'\Func\Arr::diff' => ['\Func\diff', [], [], [], false], | ||
'str_match' => ['', '//', '', null, false], | ||
'wtf' => [function ($text) { return $text; }, 'hi'], | ||
]; | ||
|
||
func($functions, ['Variable', 'Arr', 'PCRE']); | ||
func('\Func\Str\unicode_decode', '', [], [], [], false); | ||
new \Func\Alias('test', function ($text) { return $text; }, 'test'); | ||
|
||
echo str_match('/^\d+元/', '3元', '1角', true); | ||
echo unicode_decode('\u65b0\u6d6a\u5fae\u535a', 'json'); | ||
echo test('str'); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters