PHP Classes

File: Examples/common/default.php

Recommend this page to a friend!
  Classes of Christian Vigh   PHP Command Line Arguments Parser   Examples/common/default.php   Download  
File: Examples/common/default.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/default.php
Date: 1 year ago
Size: 806 bytes
 

Contents

Class file image Download
<?php
   
/***
        This example defines a command line accepting one parameter, -string_value, with a default
        value of "hello world".

     ***/
   
require_once ( dirname ( __FILE__ ) . '/../examples.inc.php' ) ;

   
$definitions = <<<END
<command>
    <usage>
        Example script that demonstrates the usage of the "default" attribute.
        Run it without any parameter ; the default value will be used :

            \$ php default.php

        Then with a value specified for the -string_value parameter :

            \$ php default.php -string_value user-specified
    </usage>

    <string name="string_value, sv" default="hello world">
        Help for the string_value parameter.
    </string>
</command>
END;

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