PHP code example of alphayax / get_opt

1. Go to this page and download the library: Download alphayax/get_opt 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/ */

    

alphayax / get_opt example snippets


$Args = \alphayax\utils\cli\GetOpt::getInstance();
$Args->setDescription('This script is a tiny example to show library features');
$verboseOption = $Args->addOpt('v', 'verbose', 'Verbose Mode');

$Args->parse();

$isVerboseMode = $verboseOption->isPresent();

$Args = \alphayax\utils\cli\GetOpt::getInstance();
$Args->setDescription('This script is a tiny example to show library features');
$fileOption = $Args->addOpt('f', 'file', 'File name', true);

$Args->parse();

// Check if file option is specified (via -f or --file)
if( $fileOption->isPresent()){
    $fileName = $fileOption->getValue();
}