我有以下代码可以让它能够将内容打印到热敏收据打印机上。
if ($_GET['action'] == 'print')
{
$printer = "\\\\localhost\\zebra";
// Open connection to the thermal printer
$fp = fopen($printer, "w");
if (!$fp){
die('no connection');
}
$data = " PRINT THIS ";
// Cut Paper
$data .= "\x00\x1Bi\x00";
if (!fwrite($fp,$data)){
die('writing failed');
}
}
虽然,当我运行它时没有任何事情发生,没有错误。如何从PHP打印?
答案 0 :(得分:0)
试试这个......
<?php
if ($_GET['action'] == 'print')
{
$printer = "\\\\localhost\\zebra";
if($ph = printer_open($printer))
{
$data = " PRINT THIS ";
// Cut Paper
$data .= "\x00\x1Bi\x00";
printer_write($ph, $data);
printer_close($ph);
}
else die('writing failed');
}
?>