note 47935 deleted from function.printer-list by sobak
| From: | sobak@php.net | Date: | Thu, 24 Nov 2016 20:30:16 +0000 |
| Subject: | note 47935 deleted from function.printer-list by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207568@lists.php.net to get a copy of this message | ||
Note Submitter: jt at jtis dot de
----
As saidyjade mentioned below, printer_list crashes Apache when you pound the resulting array too
much. I don't know why this happens, somebody should look deeper into the subject...
I have found out, contrary to saidyjade, that also just getting the NAME attribute (and remember,
it's case-sensitive! :-) can crash Apache.
Here's what I had:
<?php
foreach (printer_list(PRINTER_ENUM_CONNECTIONS) as $printer)
echo "<option value=\"" . addslashes(strtoupper($printer["NAME"])) .
"\">" . strtoupper($printer["NAME"]) . "\n";
?>
This snippet worked alright, whereas
<?php
foreach (printer_list(PRINTER_ENUM_CONNECTIONS) as $printer)
echo "<option value=\"" . addslashes(strtoupper($printer["NAME"])) .
"\"" . ((strtoupper($printer["NAME"])) ? " selected" :
"") . ">" . strtoupper($printer["NAME"]) . "\n";
?>
crashed Apache everytime the page was loaded.
I played around a bit and found this snippet not crashing:
<?php
foreach (printer_list(PRINTER_ENUM_CONNECTIONS) as $printer)
{
$curprin = strtoupper($printer["NAME"]);
echo "<option value=\"" . addslashes($curprin) . "\"" .
(($curprin == $user["drucker"]) ? " selected" : "") .
">$curprin\n";
}
?>
So, in essence you just need to be careful about how much you use the array and if necessary define
help variables that you can use as much as you want.
Hope this saves somebody some more minutes...