title: PHP printing to local Thermal Printer, does not work without networkname
body: <p>I've build a POS (Point of Sale) application in PHP that can print directly to a thermal printer. In most cases i run the application on a local webserver using WAMP.</p>
  
  <p>Part of the printing code is: </p>
  
  <pre><code>$printer = "\\\\localhost\\TM-T88V";
  
  // 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');
  }
  </code></pre>
  
  <p>This code works fine as long as the PC is connected to a network.
  I can get PHP to connect to a shared printer (either on the same pc, or on a pc in the network) by using fopen and "LOCALHOST" or "COMPUTER-NAME" : fopen("\\localhost\TM-T88V",'w');</p>
  
  <p>If I disconnect the pc from the network, PHP can no longer connect to \\localhost or \\COMPUTER-NAME.</p>
  
  <p>I've tried things like: fopen('TM-T88V'), fopen('\\.\TM-T88V'), but I keep getting "[function.fopen]: failed to open stream: No such file or directory...".</p>
  
  <p>How do I connect to a local (shared) printer (preferably by name) without having an active network connection?</p>