2016-05-17 22 views
0

如何讓所有設備打印機名稱連接到系統在網絡中使用PHP?我試了下面的代碼。PHP獲取所有打印機名稱列表連接到系統

<?php 
$getprt=printer_list(PRINTER_ENUM_LOCAL| PRINTER_ENUM_SHARED); 
$printers = serialize($getprt); 
$printers=unserialize($printers); 
//print_r($printers); 
echo '<select name="printers">'; 
foreach ($printers as $PrintDest) 
    echo "<option value=".$PrintDest["NAME"].">".explode(",",$PrintDest["DESCRIPTION"])[1]."</option>"; 
echo '</select>'; 
?> 

我得到了一個致命錯誤:調用未定義功能printer_list()在C:\ XAMPP \ htdocs中\上線測試\ getprinter.php 2

+0

你從哪裏得到「printer_list()」函數? –

+0

http://us2.php.net/manual/bg/function.printer-list.php.Is有任何解決方案 – SwR

+0

這個鏈接不工作。 – specializt

回答

0

我解決我的issue.Problem與我php_printer.dll.Once我複製php_printer.dll兼容的正確版本的PHP 5.6版。 14,開始工作。

php_printer.dll複製到ext folder.and編輯php.ini。

0

您可以按照本教程:

http://basic-programming-tips.blogspot.ch/2013/07/php-phpprinterdll-installation-and.html

轉到XAMMP主目錄(如C:\ XAMPP)

  1. 然後打開php文件夾

  2. 然後打開php.ini文件。

  3. 查找;延長= php_printer.dll

  4. 然後刪除 「;」

此重新啓動服務器,它應該工作。

PS:如果你沒有php_printer.dll =>https://github.com/maryo/php-5.5-windows-extensions/tree/master/php_printer-0.1.0-dev-5.5-vc11-x86

+0

謝謝,讓我試試。 – SwR

+0

其實,php.ini中缺少 SwR

+0

所以你必須在google上搜索下載並安裝它,然後才能添加到php.ini中 https://github.com/maryo/php-5.5 -Windows的擴展/樹/主/ php_printer-0.1.0-DEV-5.5-VC11 86 –