本文整理汇总了PHP中Zend_Console_Getopt::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Console_Getopt::setOption方法的具体用法?PHP Zend_Console_Getopt::setOption怎么用?PHP Zend_Console_Getopt::setOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Console_Getopt
的用法示例。
在下文中一共展示了Zend_Console_Getopt::setOption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
public function route(Zend_Controller_Request_Abstract $dispatcher)
{
try {
$opts = new Zend_Console_Getopt(array('help|h' => 'prints this usage information', 'action|a=s' => 'action name (default: index)', 'controller|c=s' => 'controller name (default: index)', 'verbose|v' => 'explain what is being done'));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getMessage() . "\n\n" . $e->getUsageMessage();
exit(1);
}
if ($opts->getOption("help")) {
echo $opts->getUsageMessage();
exit;
}
if (!$opts->getOption("action")) {
$opts->setOption("action", "index");
}
if (!$opts->getOption("controller")) {
$opts->setOption("controller", "index");
}
$dispatcher->setControllerName($opts->getOption("controller"))->setActionName($opts->getOption("action"));
}
示例2: dirname
<?php
$path = dirname(__FILE__);
require_once $path . '/../setup.php';
error_reporting(E_ALL);
// get the options and run CLIerror_repo()
try {
$opts = new Zend_Console_Getopt('e');
$opts->setOption('ignoreCase', true);
$options = $opts->parse();
$new = argsToArray($options);
print_r($new);
if (isset($opts->e)) {
echo "I got the a option " . $new["e"] . " \n";
$subject = "Teste zend " . Zend_Date::now();
$message = "<h2>Uma menssagem de teste em " . Zend_Date::now() . "</h2>";
//$tr = new Zend_Mail_Transport_Sendmail('contato@acaoparalela.com');
//Zend_Mail::setDefaultTransport($tr);
$mail = new Zend_Mail('utf-8');
$mail->addTo($new["e"]);
$mail->setSubject($subject);
$mail->setBodyHtml($message);
$mail->setFrom('contato@acaoparalela.com', 'Voluntário');
$mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
//print_r($mail);exit;
//Send it!
$sent = true;
try {
$mail->send();
echo "send teste \n";
} catch (Exception $e) {
示例3: getOptions
public function getOptions()
{
$opts = new Zend_Console_Getopt(array('verbose|v=i' => 'This option specifies verbose output at some level from 1-3', 'help|h' => 'This option prints out help for the command'), array());
// Don't parse the entire line here
$opts->setOption('parseAll', false);
return $opts;
}
示例4: array
* <li>
* <kbd>--help</kbd> or <kbd>-h</kbd> is an alias to <kbd>--usage</kbd>
* </li>
* <li>
* <kbd>--copyright</kbd> or <kbd>-c</kbd> prints out a copyright statement
* </li>
* <li>
* All additional arguments will be threaten as file names
* </ul>
*/
try {
$options = array('usage|u' => 'Usage - this text', 'help|h' => 'Help (alias for --usage|-u)', 'copyright|c' => 'Copyright statement');
// $objOptions will be a Zend_Console_Getopt object
$getopt = new \Zend_Console_Getopt($options);
// set explict case sensitiveness
$getopt->setOption('ignoreCase', false);
// Parse options
$getopt->parse();
} catch (\Zend_Console_Getopt_Exception $exception) {
echo $exception->getUsageMessage();
exit(3);
}
// Should the help or the usage be shown?
if (true === isset($getopt->u) or true === isset($getopt->h)) {
echo Application::getUsage($getopt);
exit(0);
}
// Should the copyright statement be shown?
if (true === isset($getopt->c)) {
echo Application::getCopyright();
exit(0);