PhpRiot
Follow phpriot on Twitter
Sponsored Link
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
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

Adding Help Messages

In addition to specifying the help strings when declaring option rules in the long format, you can associate help strings with option rules using the setHelp() method. The argument to the setHelp() method is an associative array, in which the key is a flag, and the value is a corresponding help string.

Example 129. Using setHelp()

<?php
$opts 
= new Zend_Console_Getopt('abp:');
$opts->setHelp(
    array(
        
'a' => 'apple option, with no parameter',
        
'b' => 'banana option, with required integer parameter',
        
'p' => 'pear option, with optional string parameter'
    
)
);

If you declared options with aliases, you can use any of the aliases as the key of the associative array.

The setHelp() method is the only way to define help strings if you declared the options using the short syntax.

Zend Framework