PHP将数据发送到打印机

I have a php program to generate a bill. I have formatted the bill using css in my program. Now i need to send this data to my default printer once i press the print button. Please help me with the code that sends the data to the printer

You can't do that with PHP, but you can use JavaScript fairly easily.

When the user clicks the print button, simply do the following:

window.print();

This will then call the default system print dialog.

$printerName ='';

    echo $printerName;

    $printer = $printerName;

    if($ph = printer_open($printer)) {

        printer_start_doc($ph, "Start  Doc");

       $content = "myfile.php";

       $file_handler = fopen($content, 'rw');

       $content2 = fread($file_handler, filesize($content));

       fclose($file_handler);
       // Set print mode to RAW and send PDF to printer
       printer_set_option($ph, PRINTER_MODE, "RAW");
       printer_write($ph, $content2);
        printer_end_doc($ph);
       printer_close($ph);

    }
    else "Couldn't connect...";