Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PHP CLI unexpected issues

414 views
Skip to first unread message

Dennis Lovelady

unread,
Aug 2, 2008, 11:38:42 AM8/2/08
to
I have been using PHP a very short time, and am still in the learning
process. For the most part, I'm using CGI 5.2.4-2 on a linux system,
but I would like to now start developing CLI scripts that can be used
from my Windows Vista system, or other CLI-based system.

So I have downloaded and installed PHP 5.2.6:
P:\php\gifstuff>php -v
PHP 5.2.6 (cli) (built: May 2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

I'm trying to understand why there are a number of differences between
the way this CLI works, and the way the unix system CLI works. For
example, php -r 'phpinfo();' on the Ubuntu system does what I
expected, but look what happens on Vista:
-----
P:\php\gifstuff>php -v
PHP 5.2.6 (cli) (built: May 2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

P:\php\gifstuff>php -r 'phpinfo();'

Parse error: syntax error, unexpected $end in Command line code on
line 1

P:\php\gifstuff>
-----
There are other differences too that are minor annoyances, and I'll
get around to them sometime... But HERE'S THE KILLER of the moment: My
script uses getopt() to parse incoming parameters. On the unix
system, it's working great. But I'm stopped at the top of the script
with the 5.2.6-Win system:

P:\php\gifstuff>php -cf index.php --

Warning: opendir(./captcha/fonts/): failed to open dir: No error
in P:\php\gifstuff\index.php on line 66

Fatal error: Call to undefined function getopt() in
P:\php\gifstuff\index.php on line 126

Here are those two lines:
66 ---> if ( $dh = opendir ( "./captcha/fonts/" ) ) {

126 --> $parms = getopt("ht:f:n:s:o:");

I'd like to understand why PHP feels it necessary to send me a warning
stating that there was no error (!???!!!!??) on an opendir operation,
but more I need to understand where getopt() may have gone. At first,
I thought it was an installation error, so I reinstalled, but no joy -
still gives the same result.

So, I thought I'd see major differences in the php.ini file, but there
really aren't many (except that Win has a lot of .dll includes).

Any up front suggestions, or debugging information I can provide????

Thanks!!!!
Dennis Lovelady
php-...@removeme.lovelady.com
(remove "removeme")

--
"Don't talk about yourself; that will be done when you leave."
-- Wilson Mizner

Sjoerd

unread,
Aug 8, 2008, 10:30:33 AM8/8/08
to
On Aug 2, 5:38 pm, Dennis Lovelady <php-st...@removeme.lovelady.com>
wrote:

>     Fatal error: Call to undefined function getopt() in
> P:\php\gifstuff\index.php on line 126
on Mizner

The changelog in the PHP manual says this about getopt():
5.3.0 This function is no longer system dependent and works on
Windows too.

So getopt() is available on Windows on PHP 5.3.0, but not on PHP 5.2.6.

0 new messages