File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,34 @@ This class is not workable when [register_argc_argv](http://php.net/manual/en/in
1616
1717## Usage
1818
19+ ### Example
20+
21+ run
22+ ```
23+ > example.php --name=Alexander --age=32 --sex=m
24+ or
25+ > example.php -n Alexander -a 32 -s m
26+ ```
27+
28+ example.php
29+ ``` php
30+ $config = [
31+ 'name' => 'n',
32+ 'age' => 'a',
33+ 'sex' => 's'
34+ ];
35+ $CliArgs = new CliArgs($config);
36+
37+ echo $CliArgs->getArg('name'); // Alexander
38+ echo $CliArgs->getArg('n'); // Alexander
39+
40+ echo $CliArgs->getArg('age'); // 42
41+ echo $CliArgs->getArg('a'); // 42
42+
43+ echo $CliArgs->getArg('sex'); // m
44+ echo $CliArgs->getArg('s'); // m
45+ ```
46+
1947### Config
2048
2149Note: all params from cli that you want to use should be specified in config, otherwise they will be ignored.
You can’t perform that action at this time.
0 commit comments