I created a POS (Point of Sale) application in PHP that can print directly to a thermal printer. In most cases, I run the application on the local web server using WAMP.
Part of the print code:
$printer = "\\\\localhost\\TM-T88V";
$fp = fopen($printer, "w");
if (!$fp){
die('no connection');
}
$data = " PRINT THIS ";
$data .= "\x00\x1Bi\x00";
if (!fwrite($fp,$data)){
die('writing failed');
}
This code works fine while the PC is connected to the network. I can get PHP to connect to a shared printer (either on the same PC or on a PC on the network) using fopen and "LOCALHOST" or "COMPUTER-NAME": fopen ("\\ localhost \ TM-T88V"), 'W ');
If I disconnect the computer from the network, PHP will no longer be able to connect to \\ localhost or \\ COMPUTER-NAME.
, : fopen ('TM-T88V'), fopen ('\\.\TM-T88V'), "[function.fopen]: : ...".
( ) ( ) ?