1
votes

I need to connect printer using my PHP based web application. All the printers are shared in network or it may be IP printer.

1
What does it have to do with mysqli?Dharman
I used mysql as a database thats why i mentioned italam_drupal

1 Answers

0
votes

Here's a simple way to do it with an IP printer, note that it doesn't account for interruptions in the transfer or anything, just a basic version to base yourself on:

$ip = "your IP here";
$file = "path to the file to print";

// Opening socket
if(!$fs = @fsockopen($ip, 9100)) {
    echo "Unable to connect to the printer.";
    die();
}

// Sending file to printer
fwrite($fs, file_get_contents($file));

// Closing socket
fclose($fs);