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 Aliases

You can declare aliases for options using the setAliases() method. The argument is an associative array, whose key is a flag string declared previously, and whose value is a new alias for that flag. These aliases are merged with any existing aliases. In other words, aliases you declared earlier are still in effect.

An alias may be declared only once. If you try to redefine an alias, a Zend_Console_Getopt_Exception is thrown.

Example 134. Using setAliases()

<?php
$opts 
= new Zend_Console_Getopt('abp:');
$opts->setAliases(
    array(
        
'a' => 'apple',
        
'a' => 'apfel',
        
'p' => 'pear'
    
)
);

In the example above, after declaring these aliases, -a, --apple and --apfel are aliases for each other. Also -p and --pear are aliases for each other.

The setAliases() method is the only way to define aliases if you declared the options using the short syntax.

Zend Framework