开发者

Interface to USB receipt printer in a point of sale system using PHP

I am currently writing a system in PHP that requires interface with a USB thermal receipt printer for a friend upon form submission. Currently I have read about interfacing with devices containing a parallel port but there has not been much detail on how I can use PHP to interface with a USB thermal receipt printer.

So far I have designed the receipt consisting of data that has been posted from the form. The next step would be to reproduce it on the thermal printer.

<?php
$handle = fopen("PRN", "w"); // note 1 
fwrite($handle, 'text to printer'); // note 2 
fclose($handle); // note 3 
?>

This is what I found on http://www.kksou.com/php-gtk2/Recipes/0399.php

  1. Establish the开发者_Python百科 connection with the receipt printer through PRN.

  2. Writes to the receipt printer through the file handle.

  3. Disconnect the printer.

It is rather vague? Any idea as to how it works?


Well if you are using PHP on a Win32 platform there is the Printers PECL module which can be installed. So you can use the printer using the existing driver setup.

Depending on the printer in use it may be possible to use it directly if you know the command language, EPL/ZPL/etc., set the printer to raw mode and post the commands.

Alternative:

You can access the USB bus from PHP directly, if you setup the USB as a serial port and then use the Direct IO Functions library dio. Remembering to set serial options using the mode command before commencement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜