当前位置: 首页>>代码示例>>PHP>>正文


PHP getoptions函数代码示例

本文整理汇总了PHP中getoptions函数的典型用法代码示例。如果您正苦于以下问题:PHP getoptions函数的具体用法?PHP getoptions怎么用?PHP getoptions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getoptions函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getoptions

if (isset($_GET['debug'])) {
    $_GET['verbose'] = 'on';
    $_GET['dev'] = 'on';
    $_GET['cgi'] = 'on';
}
#
# 'stats' and 'explain' would not make sense without 'sql'
#
if (isset($_GET['stats']) or isset($_GET['explain']) or isset($_GET['analyze'])) {
    $_GET['sql'] = '2';
}
#
# In case we are using this script from the command-line
#
if ($argv) {
    $_GET = getoptions($argv);
}
#
# Create or redirect to a permalink
# Neither of these return
#
$do_redir = $_GET['do_redir'];
$make_redir = $_GET['make_redir'];
if (!is_null($do_redir)) {
    do_redir($do_redir);
    exit;
} elseif (!is_null($make_redir)) {
    make_redir($_GET);
    exit;
}
#
开发者ID:kjtanaka,项目名称:mtt,代码行数:31,代码来源:index.php

示例2: php_sapi_name

                break;
            default:
                $opts["filename"] = $_SERVER["argv"][$i];
                $i++;
                break;
        }
    }
    return $opts;
}
require_once "dompdf_config.inc.php";
global $_dompdf_show_warnings;
global $_dompdf_debug;
$sapi = php_sapi_name();
switch ($sapi) {
    case "cli":
        $opts = getoptions();
        if (isset($opts["h"]) || !isset($opts["filename"]) && !isset($opts["l"])) {
            dompdf_usage();
            exit;
        }
        if (isset($opts["l"])) {
            echo "\nUnderstood paper sizes:\n";
            foreach (array_keys(CPDF_Adapter::$PAPER_SIZES) as $size) {
                echo "  " . mb_strtoupper($size) . "\n";
            }
            exit;
        }
        $file = $opts["filename"];
        if (isset($opts["p"])) {
            $paper = $opts["p"];
        } else {
开发者ID:emeraldstudio,项目名称:somosmaestros,代码行数:31,代码来源:dompdf.php

示例3: pdf_create

function pdf_create($html, $filename, $stream)
{
    /* require_once("dompdf/dompdf_config.inc.php");
        spl_autoload_register('DOMPDF_autoload');
        //$dompdf = new DOMPDF();
        //$dompdf->set_paper("a4", "portrait"); 
        //$dompdf->load_html($html);
    
        $html = 'asdfhgfh Ξ';
        //$html = utf8_encode($html);
        $dompdf = new DOMPDF(); $html = iconv('UTF-8','Windows-1250',$html);
        $dompdf->load_html($html);
    
        $dompdf->render();
        $pdf = $dompdf->output();
        if ($stream) {
            $dompdf->stream($filename.".pdf");
        }else {
            ini_set('error_reporting', E_ALL);
            if(!write_file("./files/temp/".$filename.".pdf", $pdf)) {
                echo "files/temp/".$filename.".pdf". ' -> PDF could not be saved! Check your server settings!';
               die();
                }
        }
        */
    if (!function_exists('dompdf_usage')) {
        function dompdf_usage()
        {
            $default_paper_size = DOMPDF_DEFAULT_PAPER_SIZE;
            echo <<<EOD
  
Usage: {$_SERVER["argv"][0]} [options] html_file

html_file can be a filename, a url if fopen_wrappers are enabled, or the '-' character to read from standard input.

Options:
 -h             Show this message
 -l             List available paper sizes
 -p size        Paper size; something like 'letter', 'A4', 'legal', etc.  
                  The default is '{$default_paper_size}'
 -o orientation Either 'portrait' or 'landscape'.  Default is 'portrait'
 -b path        Set the 'document root' of the html_file.  
                  Relative urls (for stylesheets) are resolved using this directory.  
                  Default is the directory of html_file.
 -f file        The output filename.  Default is the input [html_file].pdf
 -v             Verbose: display html parsing warnings and file not found errors.
 -d             Very verbose: display oodles of debugging output: every frame 
                  in the tree printed to stdout.
 -t             Comma separated list of debugging types (page-break,reflow,split)
 
EOD;
            exit;
        }
    }
    /**
     * Parses command line options
     * 
     * @return array The command line options
     */
    if (!function_exists('getoptions')) {
        function getoptions()
        {
            $opts = array();
            if ($_SERVER["argc"] == 1) {
                return $opts;
            }
            $i = 1;
            while ($i < $_SERVER["argc"]) {
                switch ($_SERVER["argv"][$i]) {
                    case "--help":
                    case "-h":
                        $opts["h"] = true;
                        $i++;
                        break;
                    case "-l":
                        $opts["l"] = true;
                        $i++;
                        break;
                    case "-p":
                        if (!isset($_SERVER["argv"][$i + 1])) {
                            die("-p switch requires a size parameter\n");
                        }
                        $opts["p"] = $_SERVER["argv"][$i + 1];
                        $i += 2;
                        break;
                    case "-o":
                        if (!isset($_SERVER["argv"][$i + 1])) {
                            die("-o switch requires an orientation parameter\n");
                        }
                        $opts["o"] = $_SERVER["argv"][$i + 1];
                        $i += 2;
                        break;
                    case "-b":
                        if (!isset($_SERVER["argv"][$i + 1])) {
                            die("-b switch requires a path parameter\n");
                        }
                        $opts["b"] = $_SERVER["argv"][$i + 1];
                        $i += 2;
                        break;
                    case "-f":
//.........这里部分代码省略.........
开发者ID:imranweb7,项目名称:msitc-erp,代码行数:101,代码来源:dompdf_helper.php


注:本文中的getoptions函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。