PHP不读取命令行参数


PHP not reading command line params

我创建了一个小脚本,用于从某些链接中"清理"站点地图文件。我想我以前使用它没有问题,但现在无法使用它,因为一个奇怪的错误-没有命令行参数被读取。

我可能看错地方了,但我谷歌了一下,我得到的是我已经实现的用法。

请检查以下代码片段:

 if(count($argv) != 4) {
            echo "'n'nUSAGE: php cleanSitemap.php <input file> <output file> <bad str>'n"
                    ."This script parses <input file>, skipping all the sitemap XML elements containing <bad str>,'n"
                    ."writting only 'good' XML elements into sitemap.'n"
                    ."Sample: php cleanSitemap.php sitemap.xml sitemap_clean.xml protect-x'n"
                    ."'n";
            echo "You entered " . count($argv) . " parameters.'n";
            exit();
    }

你认为问题在哪里?

编辑:为了简化,我用以下内容创建了test.php:

<?php
        echo count($argv) ."'n";
        print_r($argv);
        echo "'n";
?>

-bash-3.2$/web/cgi-bin/php5 test.php 1 2 3 45

的content - type: text/html

0

好吧…在写这篇文章的时候,我想我可能已经得到了一些东西:这是Godaddy共享主机上使用的php5客户端。也许它以某种方式设置为不能通过命令行使用?或者,如果使用,它不接受命令行参数。

啊啊啊啊啊啊…好吧,我完全是个新手。

我刚刚发现,这个问题真的是有关使用不正确的php二进制文件…也就是说,"正确的"可以在/usr/local/php5/bin/php中找到。

我为这个错误感到非常抱歉。