PHP Classes

File: resources/example.php

Recommend this page to a friend!
  Classes of jawira   Mini PHP Getopt   resources/example.php   Download  
File: resources/example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Mini PHP Getopt
Extract command line parameter values using getopt
Author: By
Last change:
Date: 4 years ago
Size: 537 bytes
 

Contents

Class file image Download
<?php /** @noinspection PhpUnhandledExceptionInspection */

require __DIR__ . '/../vendor/autoload.php';

use
Jawira\MiniGetopt\MiniGetopt;

// Setup
$mg = new MiniGetopt();
$mg->addRequired('f', 'format', 'Format to export', 'png|gif|svg');
$mg->addOptional('r', 'retry', 'Retry on error', 'count');
$mg->addOptional('q', '', 'Quiet mode', 'yes|no');
$mg->addNoValue('v', 'verbose', 'Display verbose messages');
$mg->addNoValue('', 'version', 'Show version');

// Calling getopt function
echo var_export($mg->getopt(), true) . PHP_EOL;