PHP Classes

File: Examples/common/multiple.php

Recommend this page to a friend!
  Classes of Christian Vigh   PHP Command Line Arguments Parser   Examples/common/multiple.php   Download  
File: Examples/common/multiple.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Command Line Arguments Parser
Parse and extract arguments from the command line
Author: By
Last change: Update of Examples/common/multiple.php
Date: 1 year ago
Size: 864 bytes
 

Contents

Class file image Download
<?php
   
/***
        This example defines a command line accepting one parameter, -string_value, having the
        "multiple" attribute set to true, so that you can specify it multiple times.
     ***/
   
require_once ( dirname ( __FILE__ ) . '/../examples.inc.php' ) ;

   
$definitions = <<<END
<command>
    <usage>
        This example defines a command line accepting one parameter, -string_value, having the
        "multiple" attribute set to true, so that you can specify it multiple times.

        Example usage :

        $ php multiple.php -sv string1 -sv string2
    </usage>

    <string name="string_value, sv" multiple="true" default="*** no value specified ***">
        Help for the string_value parameter.
    </string>
</command>
END;

   
$cl = new CLParser ( $definitions ) ;
    echo
"Value(s) of the -string_value parameter : " ; print_r ( $cl -> string_value ) ; echo "\n" ;