RE: [PHP-DOC] printer_open() documentation error
| From: | Greg Jackson | Date: | Tue, 29 Mar 2005 23:17:04 +0000 |
| Subject: | RE: [PHP-DOC] printer_open() documentation error | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969367150@lists.php.net to get a copy of this message | ||
Thanks Philip for the quick response!
You're right, since my original post I found that it will return NULL or
FALSE under different conditions. If the printer doesn't exist I get FALSE.
I'm getting NULL for a valid printer that is for some reason refusing the
connection.
So I guess it is a bug, but maybe a useful one :)
Regards,
Greg
-----Original Message-----
Hello!
I don't really have an answer except that according to the
source here:
http://lxr.php.net/source/pecl/printer/printer.c#256
It can return false but also has a chance to return nothing
which doesn't seem like a good idea. That is, if the
following condition fails nothing happens:
if (DocumentProperties(NULL, resource->handle,
resource->name, resource->pi2->pDevMode, NULL,
DM_OUT_BUFFER) == IDOK) {
I have no idea what this means but I consider this a PHP
bug, not a documentation bug. I suggest you open up a bug
report for this extension. I'm not sure how to report it
though considering this extension is PECL yet cannot be
found at pecl.php.net so I guess that's a bug too :) Once
fixed, we'll document the change (I added a user comment for
now).
Quick fix: Just know that it may return NULL or FALSE so
using a strict type check may not be the best route here.
Regards,
Philip
On Wed, 30 Mar 2005, Greg Jackson wrote:
> Hi
>
> I'm not sure if this is a documentation error or a bug in php_printer.dll
> but here goes...
>
> printer_open() is returning NULL upon failure, not FALSE i.e. the
following
> code doesn't work:
>
> <?php
> $printer = "\\\\greg-mac\\LaserJet_5";
> if(($conn_printer = printer_open($printer)) === FALSE)
> die("Could not connect to $printer\r\n");
> var_dump($conn_printer);
> printer_close($conn_printer);
> ?>
>
> This does:
>
> <?php
> $printer = "\\\\greg-mac\\LaserJet_5";
> if(($conn_printer = printer_open($printer)) === NULL)
> die("Could not connect to $printer\r\n");
> var_dump($conn_printer);
> printer_close($conn_printer);
> ?>
>
> Version info:
>
> PHP 4.3.10 (cli) (built: Dec 14 2004 17:48:04)
> php_printer.dll 29-Mar-2005 16:28 40k
>
>
> Best regards,
> Greg Jackson
> Web Administrator
>
> Active Components (NZ) Ltd
> PO Box 100-544, Auckland
> New Zealand
>
> DDI: +64-9-443 9519
> Sales: +64-9-443 9500
> Fax: +64-9-443 9502
> http://www.activecomponents.com/
>