Last Updated: February 25, 2016
·
277
· fpisa

Simple class to wrap getopt()

I've coded a simple class to make use of getopt() PHP function.

Simple usage:

$options = new SimpleOpt($shortopts, $longopts);

 // dies if not provided
$required = $options->getRequiredOption('r');

 // if '-o' option is not given, returns 'default'
$optional = $options->getOption('o', 'default');

Source at GitHub.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#php
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside