PHP code example of golgote / console_getargs2

1. Go to this page and download the library: Download golgote/console_getargs2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

golgote / console_getargs2 example snippets


array(
 longname => array('short'   => Short option name,
                   'max'     => Maximum arguments for option,
                   'min'     => Minimum arguments for option,
                   'default' => Default option argument,
                   'desc'    => Option description)
)


try {
  $args = new Console_Getargs2($config);
} catch (Console_GetArgs2_UserException $e) {
  echo $e->getHelp();
} catch (Console_GetArgs2_Exception $e) {
  echo $e->getMessage();
}
echo 'Verbose: '.$args['verbose']."\n";
if (isset($args['bs'])) {
 echo 'Block-size: '.(is_array($args['bs']) ? implode(', ', $args['bs'])."\n" : $args['bs']."\n");
} else {
 echo "Block-size: undefined\n";
}
echo 'Files: '.(isset($args['file']) ? implode(', ', $args['file'])."\n" : "undefined\n");
if (isset($args['n'])) {
 echo 'Nodes: '.(is_array($args['n']) ? implode(', ', $args['n'])."\n" : $args['n']."\n");
} else {
 echo "Nodes: undefined\n";
}
echo 'Log: '.$args['log']."\n";
echo 'Debug: '.(isset($args['d']) ? "YES\n" : "NO\n");