1. Go to this page and download the library: Download jdwx/args 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/ */
jdwx / args example snippets
declare( strict_types = 1 );
rgv );
$st = $args->shiftString();
# Based on the shell example above, $st now equals "Hello,"
# If the next argument is "prefix_example," $st will be set to "example."
# In this example, the consume flag is not set, so the argument will not
# be consumed.
if ( $st = $args->peekString( 'prefix_' ) ) {
echo "Got: $st\n";
$st2 = $args->shiftString();
assert( $st2 === $st ); # Argument was not consumed.
} else {
echo "Nope!\n";
}
$rKeywords = [ 'example', 'demo', 'test' ];
# If the next argument is "example," $st will be set to "example." In this example,
# the consume flag is set so the argument is consumed if (and only if) it matches.
# The default is kept as false for consistency with peekString(), but usually
# you do want to consume keyword-matching arguments.
if ( $st = $args->peekKeywords( $rKeywords, i_bConsume: true ) ) {
echo "Got: $st\n";
} else {
echo "Nope!\n";
}
$args = new JDWX\Args\Arguments( $argv );
$rOptions = $args->handleOptions();
if ( in_array( 'help', $rOptions ) ) {
echo "Usage: $argv[0] [options] [arguments]\n";
echo "Options:\n";
echo " --help Display this help message\n";
exit( 0 );
}
bash
YourPrompt$ ./example.php Hello, world.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.