note 75202 deleted from function.fsockopen by nicobn
| From: | nicobn@php.net | Date: | Sun, 08 Jul 2007 17:27:29 +0000 |
| Subject: | note 75202 deleted from function.fsockopen by nicobn | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128304@lists.php.net to get a copy of this message | ||
Note Submitter: bigpojo at gmail dot com
----
This works from a Windows machine. I have yet to try it from a *nix box.
<?php
function print_job($job_data,$ip) {
@$ps = fsockopen($ip,9100,$errno,$errstr,3);
if($ps) {
fwrite($ps,$job_data);
fclose($ps);
}
else {
echo("$errstr ($errno)\n");
}
}
/*Usage
$print_string = "This is line 1.\r\nThis is line 2.\r\nThis should be line 3.\r\n";
$ip_printer = "192.168.X.X";
print_job($print_string,$ip_printer);
*/
?>