-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
49 lines (40 loc) · 1.03 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
* PHP parameters and Options handler
*
* Usage sample
*
* @package System
* @author Vallo Reima
* @copyright (C)2015
*/
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
ini_set('log_errors', false);
/* sample default options */
$def = array(
'sgn' => true,
'exf' => ['*.min.*'],
'sfx' => '_pkd',
'aon' => [],
'arc' => 'zip',
'tml' => 30
);
/* sample request */
$_GET = array('sgn' => '', 'arc' => '7z','aon' => ['add']);
$_POST = array('sfx' => '', 'arc' => 'tar', 'exf' => null);
require('ParmOpts.php'); // load the class
$obj = new ParmOpts(); // instantiate with default priority
$opt = $obj->Opts($def); // assign settings, update with the request values
$prm = $obj->Get(); // request parameters
/* display result */
header('Content-Type: text/html; charset=utf-8');
echo 'ParmOpts usage sample<br><br>';
echo 'Options<br>';
echo '<pre>';
print_r($opt); // updated options
echo '</pre>';
echo 'Parameters<br>';
echo '<pre>';
print_r($prm); // accepted parameters
echo '</pre>';