【问题标题】:Issue with getting options from Command line从命令行获取选项的问题
【发布时间】:2013-12-04 08:38:47
【问题描述】:

好的,我知道getopt

所以,假设我想要选择(例如ab),我会做一个getopt("a:b:") 和 像php myscript.php -a someAvalue -b someBvalue 这样的东西将完全可以通过按应有的方式存储的选项值来识别。

现在,如果我希望能够识别最常见的语法类型并仍然让getopt 工作:

php myscript.php somefile.txt -a someAvalue -b someBvalue

有什么想法吗?

【问题讨论】:

    标签: php command-line-interface getopt


    【解决方案1】:

    您可以使用变量访问命令行参数:$argv[]

    【讨论】:

    • 请记住,它仅在PHP_SAPI === 'cli'时可用
    • 是的,没错。但是:当使用上述语法时,getopt 会中断。有什么想法吗?
    猜你喜欢
    • 2021-11-27
    • 1970-01-01
    • 1970-01-01
    • 2020-02-23
    • 2011-06-24
    • 2014-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多