PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Adding Option Rules

You can add more option rules in addition to those you specified in the Zend_Console_Getopt constructor, using the addRules() method. The argument to addRules() is the same as the first argument to the class constructor. It is either a string in the format of the short syntax options specification, or else an associative array in the format of a long syntax options specification. See Declaring Getopt Rules for details on the syntax for specifying options.

Example 132. Using addRules()

<?php
$opts 
= new Zend_Console_Getopt('abp:');
$opts->addRules(
  array(
    
'verbose|v' => 'Print verbose output'
  
)
);

The example above shows adding the --verbose option with an alias of -v to a set of options defined in the call to the constructor. Notice that you can mix short format options and long format options in the same instance of Zend_Console_Getopt.

Zend Framework